WordPress.org

Ready to get started?Download WordPress

Forums

Parse Error? (17 posts)

  1. Anonymous
    Unregistered
    Posted 9 years ago #

    I've just installed WP, and it's working, hitting the DB OK and everything, but I keep getting these perplexing parse errors on various pages. Here's one example:
    on
    wp-admin/options-general.php
    when i submit the form, I get:
    Parse error: parse error, unexpected $ in /home/bullrush/public_html/wordpress/wp-admin/optionhandler.php on line 108
    nothing looks amiss on line 108 or anywhere near it, to my not-very-php-capable eye.
    I've tried re-downloading WP, deleting the offending files, and reuploading them.
    No dice.
    any ideas?
    thanks!
    GD

  2. Anonymous
    Unregistered
    Posted 9 years ago #

    I'm having the same problem--- could it be due to the fact that I'm using a MAC os 9?

  3. Anonymous
    Unregistered
    Posted 9 years ago #

    I don't see how the client OS would affect things -- the parse error happens when the server can't make sense of the PHP code.

  4. It looks like you have an unexpected $ in optionhandler.php on line 108. What it is actually referring to is the output, so navigate your browser over to optionhandler.php and save the source. On line 108, you'll find an unexpected $. Now, look in the actual optionhandler.php and try to find the line that looks similar to line 108 in the source. There you will find your unexpected $. You could also delete the old optionhandler.php from your server and upload a fresh on from the WP download.

  5. durf
    Member
    Posted 9 years ago #

    I'm getting the exact same parse error. Line 108, optionhandler.php . . . But I can't view as source, since the only source visible when I go to that page in the browser is the error message.

    Line 108 looks like this in my install (which is brand new and not altered a bit--I was trying to make some changes in the settings when it started doing this):

    $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $tableoptionvalues WHERE option_id = $option->option_id");

    The optionhandler.php on my local HD (where I unzipped the install files) looks exactly the same. Do I need to delete a character here?

  6. durf
    Member
    Posted 9 years ago #

    No ideas? If this is what the files do "out of the box" I can't really use WordPress.

  7. Do you have any plugins installed? Have you made any code modifications?

  8. durf
    Member
    Posted 9 years ago #

    Thanks for your reply!

    I've made no changes whatsoever. This was a fresh, clean install, and I was going in there for the first time to make some changes to the settings (the title of the weblog and so forth). Hitting the "Update Options" button gets me that parse error. I'd try uploading that .php file again, but the unpacked one on my local disk is the same as the one that's up there now.

  9. Hm, it sounds like you got a bad file upload or something of that sort. Since you just started out, would you be ok with deleting all of the files and the MySQL database, then download a fresh copy of WordPress and start over?

    Do not overwrite the files. overwriting files via FTP can lead to incomplete transfers.

    Follow these installations instructions carefully: http://codex.wordpress.org/Installing_WordPress

  10. durf
    Member
    Posted 9 years ago #

    Yeah, I might have to go that route . . . Hey, it's only my free time, right? :-)

    Here's hoping it works better the second time.

  11. hidden_premise
    Member
    Posted 9 years ago #

    From my experience of php its usually within 5 lines of your error tho so try reading the context of the situation. Look for absolutely any syntax errors not just random $'s. Look for unclosed clauses (no }'s) or quotation issues. Another thing that could be causing this is something in your database, some sort of input you put in is not getting escaped and is therefore creating a parse error. Something like a slash or quotes... Try checking through all your input via myphpadmin and escaping all your punctuation...

  12. durf
    Member
    Posted 9 years ago #

    The problem is that I know nothing of PHP syntax . . . I could post the whole section of code here, I guess:

    function validate_option($option, $name, $val) {
    global $wpdb, $tableoptionvalues;
    $msg = '';
    switch ($option->option_type) {
    case 6: // range
    // get range
    $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $tableoptionvalues WHERE option_id = $option->option_id");
    if ($range) {
    if (($val < $range->optionvalue_min) || ($val > $range->optionvalue_max)) {
    $msg = "$name is outside the valid range ($range->optionvalue_min - $range->optionvalue_max). ";
    }
    }
    } // end switch
    return $msg;
    } // end validate_option

  13. hidden_premise
    Member
    Posted 9 years ago #

    From what i know about php i see no errors in syntax, except possibly the line "case 6: // range" I am not sure what the hell the whole case 6 thing is... try commenting it out and uploading. Other than that syntax is perfect. I'm really starting to think some unescaped value from your database that is being run through here is what is causing your trouble.. Make sure all of your punctuation marks are escaped.

  14. durf
    Member
    Posted 9 years ago #

    Oog . . . I ended up zapping everything, setting up a new database and user, reinstalling 1.5 completely fresh, and now I've run into this one:

    Parse error: parse error, unexpected $ in /home/durf/public_html/news/wp-includes/wp-db.php on line 347

    Line 347 of this file (and all the surrounding lines) is right in the middle of the HTML code. No $ in sight.

  15. ajit
    Member
    Posted 9 years ago #

    <?php

    $flag=true;
    $link=mysql_connect("localhost", "ajit", "ajit")
    or die ("Could not connect to MySQL");

    mysql_select_db ("ajit")
    or die ("Could not select database");
    $submitSearch=$_POST['submit'];
    $name=$_POST['search'];
    $add=$_POST['add'];
    if(isset($link))
    { if(isset($submitSearch))
    {
    if(isset($name))
    {

    $searchResult=mysql_query('select * from personInfo where name LIKE "$name" ORDER BY date DESC;')
    or die ("Query failed");
    if(mysql_num_rows($searchResult)>0 ){
    display_table($searchResult);
    }
    else{
    echo"no such row obtained";
    }
    }
    else{echo"Give the name of person you want to search";}

    }
    elseif(isset($add))
    {

    Header("Location: http://192.168.0.10/~ajit/infoform.php");
    }

    else{
    $result = mysql_query('select * from personInfo order BY date DESC;')
    or die ("Query failed");
    $num=mysql_num_rows($result);

    display_table($result);
    }

    }

    else{
    echo"could not connect to the database";

    }

    /* THIS TABLE WILL DISPLAY ALL FETCHED ROWS FROM TABLE + ADD EDIT LINK+
    +E-MAIL LINK*/

    function display_table($result)
    {
    if(isset($result))
    {
    $subject="REMINDER ABOUT WORK";
    $messege="Hello sir/madam";
    print "<table border=1><br>";
    $temp=0;
    echo"<tr>";
    for($temp=0;$temp<18;$temp++)
    {
    echo"<td>";
    $fieldname= mysql_field_name($result, $temp);
    echo"$fieldname";
    echo"</td>";
    }
    echo"</tr>";

    while ($line = mysql_fetch_array($result))
    {
    echo "<tr>";

    foreach ($line as $key=>$value)
    {
    $temp=0;
    if ((mysql_field_name($result, $temp)=="emailid"))
    {
    echo "<td>";
    @mail($value, $subject, $message );

    //echo'<a href="mailto:$value?subject="Feedback">E-MAIL</a>';
    echo "</td>";
    }

    else{
    echo "<td>";
    echo"$value";
    echo"</td>";
    }

    $row = mysql_fetch_array($result,MYSQL_NUM);
    $id=$row[0];
    //echo"<td align=\"center\" bgcolor=\"#5647A1\" onclick=\"window.location.href='editform.php';\"> EDIT </td>";

    echo"<td></td>";

    $temp++;
    echo "</tr>";
    }
    print "</table><br>";
    }
    }
    else{
    echo"NO RESULTS FOUND";

    }
    }

    ?>

    <html>
    <head>
    <title>PERSON INFORMATION</title>
    </head>
    <body>

    <form method="post" >
    <input type="text" name="search" <br>
    <label> SEARCH PERSON NAME</label>
    <input type="submit" name="submit" value="SEARCH">
    <input type="submit" name="add" value="ADD_NEW_RECORD">
    </form>
    </body>
    </html>

  16. ajit
    Member
    Posted 9 years ago #

    hi
    can anybody will help me?

    gettin error parse error, unexpected $ on last line

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.