[RESOLVED] Parse error: syntax error, unexpected T_STRING
What's wrong with the above code?
mysql_query("INSERT INTO users (Username, Password, Email)
VALUES ('abc', '123123', 'firstname.lastname@example.org')");
My guess would be that the root cause is in the preceding line(s), such as a missing closing double-quote.
Never mind, I fixed it. I was missing a ";"
Last edited by narutodude000; 04-28-2010 at 07:55 PM.
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
The other suggestion is to get into the habit of specifying your link, that is, ($query, $link) instead of just ($query).
$query = "INSERT INTO users (Username, Password, Email)
VALUES ('abc', '123123', 'email@example.com')";
$result = mysql_query($query, $link);
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.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)