SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error: syntax error, unexpected T_STRING

    I`m brand new to PHP, currently working my way through Kevin Yanks book. I got stuck with the following error message and cant seem to locate the problem: Parse error: syntax error, unexpected T_STRING. Any input is deeply appreciated.

    Here is the line that gets the error message:
    Code:
    $error = 'Error adding submitted player: ' . mysqli_error($link);
    And here is the code surrounding it:
    Code:
    if (isset($_POST['lastname']))
    {
      $lastname = mysqli_real_escape_string($link, $_POST['lastname']);
      $sql = 'INSERT INTO players SET
          lastname="' . $lastname . '";
      if (!mysqli_query($link, $sql))
      {
        $error = 'Error adding submitted player: ' . mysqli_error($link);
    	include 'error.html.php';
    	exit();
      }

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    It looks as though you are not closing the SQL statement correctly.

    Try this code:
    PHP Code:
      $sql '
                  INSERT INTO players 
                  SET lastname="
               ' 
          
    .  $lastname 
        
    .   '"';          
      echo 
    $sql;    
      die; 



    .
    Last edited by John_Betong; May 2, 2010 at 21:01. Reason: spelling and formatting
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did the trick. Thanks, John!

  4. #4
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Aarian View Post
    That did the trick. Thanks, John!
    Man thanks - glad I was able to help.


    .
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014


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
  •