![]() |
MySQL INSERT INTO
Hi all,
First of im new anf it took me ages to fine the dam register page! Ok my problem, I am trying to do a registration page. All is going well untill it goes to put the data into the Database. Here my code: Code:
mysql_query("INSERT INTO `users` (username, password, email, activecode, activated, tut, status)The fields I am inserting into arent the only fields in the Table. Will this stop it? Just inserting into the defined fields and leaving the rest blank would be great letting them default. If not I will do it the hard way. Thanks for any posts, help and advice. Dean. |
Have you checked mysql_error() to see what it says?
PHP Code:
|
Thanks for the reply DI.
I put that line in and got this error: Quote:
Will that be because I am only putting data into a few fields of the Table, not the whole of the table? I still dont understand that, I will have another look in 10 mintues. Thanks, Dean. |
It could be as simple as putting quotes around your values. Try;
PHP Code:
|
You get that error because you're sending strings without quotes to the database. That works only if the destination field is of type number (any - double, int, what ever) and the value you're trying to insert/change is a number, aswell.
|
Ok, now I get:
Query failed: 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 ''username', 'password', 'activated', 'online', 'email', 'status', 'tut', 'active' at line 1 Im confused. The code is: Code:
mysql_query("INSERT INTO `users` ('username', 'password', 'activated', 'online', 'email', 'status', 'tut', 'activecode')The code is inserting into the only columns in the table in order. Thanks for the responses, Dean. |
Try removing the quotes from your column names, but keep them around your values, and see if that does the trick.
-m |
Or try use the ` quotes insted of single quote signs
|
| All times are GMT. The time now is 10:51 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0