views:

54

answers:

3
+2  A: 

You really should be checking for errors in your query. Even something as basic as:

mysql_query($query) or die(mysql_error());

Any time you do a mysql function you should check for errors, or have a method of catching exceptions (if using an applicable interface, since the default mysql functions don't throw exceptions).

It could be messing up on a few points.

Also, as a hint, sprintf works wonderfully if you're writing queries out.

Codeacula
Thanks for that! I got an error saying to check for valid syntax at line 2, so then I realised that maybe it was the single quote on the top part of the query (before VALUES), So I removed the single quotes. Then, I got another error, same thing: **"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Number, Account ID, First Name, Last Name, Date ' at line 2"**
lucifer
Could it be possible that it's because of the spaces inbetween the Names (i.e. Account ID etc)?
lucifer
Not to mention the use of invalid identifier quotes (you should use ```)...
ircmaxell
Problem solved! It WAS the spaces inbetween the Column names. That's so strange because MySQL Query Browser let me use spaces, just like a spreadsheet. Oh well, now I know. Now that it's working, time to make it secure!!! :) Thanks for helping, Codeacula! :-)
lucifer
You mean, use ` instead of '? :) Thanks, ircmaxell!
lucifer
The Query Browser will correct it for you, obviously. And use \` instead of ', but I would also make sure to check for ` as part of your SQL sanitizing and handle as desired, since 'mysql_escape_string()' isn't aware of it.
Codeacula
Do not use `mysql_escape_string`! It's deprecated and doesn't work correctly. Use `mysql_real_escape_string`. And it doesn't matter if it knows about ```, since the result will be put inside of quotes, so it won't be parsed as an identifier token anyway...
ircmaxell
I was lazy and left out real. My bad.
Codeacula
Thank you Codeacula :)
lucifer
Thanks ircmaxell :)
lucifer
+2  A: 

You have an error in your SQL query. You're getting "Account created" because you're not testing for it.

eusto
I have fixed the problem. Thanks for helping :)
lucifer
A: 

So, I've managed to figure out what was going to, thanks to all your advice :) As it turns out, it wasn't working because I was using spaces inbetween the Column Names (i.e. Account ID should be AccountID). So I just removed spaces from the table columns, and also from the php code.

Thanks all for your help!

lucifer