• would greatly appreciate some help:

    Ok so getting white screen of death, ran debugger and got following syntax error:

    Parse error: syntax error, unexpected ‘bfa_ata4’ (T_STRING), expecting ‘,’ or ‘;’ in D:\home\site\wwwroot\wp-content\themes\atahualpa\functions.php on line 273

    Line 273 is as follows:

    if (delete_option(‘bfa_ata4’)) echo ‘<span style=”color:green;font-weight:bold;”>Successfully deleted option ‘bfa_ata4′ …</span>’;

    whole function is:

    function bfa_delete_bfa_ata4() {
    check_ajax_referer( “delete_bfa_ata4” );
    if (delete_option(‘bfa_ata4’)) echo ‘<span style=”color:green;font-weight:bold;”>Successfully deleted option ‘bfa_ata4′ …</span>’;
    else echo ‘<span style=”color:green;font-weight:bold;”>Something went wrong…</span>’;
    die();
    }

    Have deactivated all plugins but does not make a difference

    thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You’re using the single-quotes inside a string using single quoted. Thats the problem. Any single quotes inside the string should be escaped, as \'

    Thread Starter ouzifeng

    (@ouzifeng)

    thanks very much for your advice, I have no changed to:

    if (delete_option(‘bfa_ata4’)) echo ‘<span style=”color:green;font-weight:bold;”>Successfully deleted option “bfa_ata4” …</span>’;

    However the letter ‘s’ is now not displaying correctly (you can see here)

    http://roburwordpress.azurewebsites.net/

    is this correct?

    Thread Starter ouzifeng

    (@ouzifeng)

    function bfa_delete_bfa_ata4() {
    check_ajax_referer( “delete_bfa_ata4” );
    if (delete_option(‘bfa_ata4’)) echo ‘<span style=”color:green;font-weight:bold;”>Successfully deleted option \’bfa_ata4\’ …</span>’;
    else echo ‘<span style=”color:green;font-weight:bold;”>Something went wrong…</span>’;
    die();
    }

    Now have is as \’, however getting the same syntax error

    Then change the single quotes for double quotes.

    It’s one thing that I should have remembered. PHP treats strings between double-quotes and single-quotes differently. If you use double-quotes, the text is evaluated and parsed, but using single quotes, it’s taken “as is”.

    function bfa_delete_bfa_ata4() {
        check_ajax_referer( "delete_bfa_ata4" );
        if (delete_option('bfa_ata4')) {
            echo '<span style="color:green;font-weight:bold;">Successfully deleted option "bfa_ata4" ...</span>';
        }
        else {
            echo '<span style="color:green;font-weight:bold;">Something went wrong...</span>';
        }
        die();
    }
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Syntax error’ is closed to new replies.