www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Parse error: syntax error, unexpected T_STRING

  1. #1
    Join Date
    Mar 2010
    Posts
    701

    resolved [RESOLVED] Parse error: syntax error, unexpected T_STRING

    mysql_query("INSERT INTO users (Username, Password, Email)
    VALUES ('abc', '123123', 'abc@hotmail.com')");
    What's wrong with the above code?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    My guess would be that the root cause is in the preceding line(s), such as a missing closing double-quote.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2010
    Posts
    701
    Never mind, I fixed it. I was missing a ";"
    Last edited by narutodude000; 04-28-2010 at 06:55 PM.

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    700
    Yup. Missing ";"s will get you every time.
    You might want to look at Komodo from ActiveState. Komodo's an editor that lays code out for you, and pre-empts the function name while you're typing.

    For instance, if you type "mysql_q" it will know you're looking for mysql_query. It will make your job easier.

    And there's a free version!

    I would also separate the sql from the query. It will make your code easier to read, and deliver some functionality down the track when you step up a level in your scripting.

    So instead of your example above, I would make it
    PHP Code:
    $query "INSERT INTO users (Username, Password, Email)
    VALUES ('abc', '123123', 'abc@hotmail.com')"

    $result mysql_query($query$link); 
    The other suggestion is to get into the habit of specifying your link, that is, ($query, $link) instead of just ($query).

    At the moment, you're probably using a single data file, but mySQL allows you to use many, each specified with a different link. As your application grows (it will) and you add more features (you will), it will save you the trouble of having to go back and rework your queries.

    Cheers
    CTB
    Oh Lord, please help me be the person my dog thinks I am.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles