SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'T_STRING' or 'T_VARIABLE' etc.

    First off, what does this error mean?

    Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\phpdev\www\public\php\mb\mysql\board.php on line 34
    I got this by using this code here:

    PHP Code:
     while($row = @mysql_fetch_array($board_query)) { 
      if(
    $row['email'] != NULL) { $name "<a href=\"mailto:$row['email']\">$row['name']</a>"
    And I can't see what is wrong with it. The if($row['email' != NULL) is line 34.

    Thanks

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Line 33 is missing a semicolon or a } brace.
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it? Line 33 is the while() statement that I added in here, and It doesn't look like it does....

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post more code please ?
    - website

  5. #5
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $mysql_connect = @mysql_connect($dbhost$dbuser$dbpass);
     
    $mysql_select_db = @mysql_select_db($dbname$mysql_connect);

     
    $board_sql "SELECT * FROM `$boardtable` WHERE `parent_id`=1 ORDER BY `thread_id` ASC;";
     
    $board_query = @mysql_query($board_sql$mysql_connect);
     while(
    $row mysql_fetch_array($board_query)) {
      echo 
    'hi';
      echo 
    $_SERVER['REMOTE_ADDR'];
      
    //if($row['email'] == '') { $name = "<a href=\"mailto:$row['email']\">$row['name']</a>"; }
      //else { $name = $row['name']; }
      //$id = $row['thread_id'];
      //$thread['$id'] = "   long info";
     

    It seems to be the while() function because even though I commented all of the code within it and added a simple echo(), nothing shows up...no text...no error...

    Also, it comes up as row 33 because I have HTML before the <?php.

  6. #6
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that would propably be because either the query returns no results or it returns an error. modify the line with the query to this:
    PHP Code:
    $board_query mysql_query($board_sql$mysql_connect) or die(mysql_error()); 
    this should output error, paste it here....

    Off Topic:

    When you are creating and developing your scripts you really shouldn't mute functions with the @ sign
    - website

  7. #7
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    A typical check would be :

    if( !$results || mysql_num_rows( $results ) < 1){
    // Display error or ignore
    } else {
    while( ($result = mysql_fetch_array( $results )) == true){
    //do stuff
    }
    }

  8. #8
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a list of all the tokens used, which may help you in future

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  9. #9
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help guys. Got it to work

  10. #10
    SitePoint Wizard triexa's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    2,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just looked at your original post... you're line 34 is this:

    PHP Code:
    if($row['email'] != NULL) { $name "<a href=\"mailto:$row['email']\">$row['name']</a>"
    You have a { but not a } at the end of that line.
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
    Follow us on Twitter

  11. #11
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, dunno why it didn't show up here, but I do have it.

    The problem was actually because I had the variable $row['name'] in a variable name, which shouldn't have made a difference in my opinion, but caused the error.

  12. #12
    SitePoint Wizard triexa's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    2,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh okay
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
    Follow us on Twitter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •