Results 1 to 4 of 4

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

  1. #1
    Join Date
    Mar 2010

    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
    My guess would be that the root cause is in the preceding line(s), such as a missing closing double-quote.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

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

  4. #4
    Join Date
    Aug 2003
    Sydney, Australia
    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.

    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