|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Error Creating Table, Someone Help please
I received the following error:
You have an error in your SQL syntax near ''test' ('name' VARCHAR( 32 ) NOT NULL ,'comment' VARCHAR( 255 ) NOT NULL ,'email' at line 1 using the follwing code: $query2="CREATE TABLE $username ('name' VARCHAR( 32 ) NOT NULL ,'comment' VARCHAR( 255 ) NOT NULL ,'email' VARCHAR( 50 ) NOT NULL ,'site' VARCHAR( 64 ) NOT NULL ,'ip' VARCHAR( 50 ) NOT NULL ,'id' INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY)"; mysql_query($query2); $username is a variable that has ' added in the beginning and ' added at the end. In between the ' ' is the username the user submitted from a form. I have tried to fix the problem myself and cant, can someone help? I would really appreciate it! Last edited by EvilXParser : August 25th, 2003 at 11:52 AM. |
|
#2
|
|||
|
|||
|
Umm not to sure about this, but I don't think you're supposed to have the variable in there when you create a table..
|
|
#3
|
|||
|
|||
|
The variable has nothing to do with it.
The problem is that you have quotes around your column names instead of the backtick. ' versus ` The backtick is on the key just to the left of the #1 on your keyboard. You actually don't have to have this surrounding your column names... it is nice to qualify the names like that, but it would work equally well if you ommited the quotes around the column names altogether.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#4
|
|||
|
|||
|
Thanx alot, I followed ur advice and changed it to:
$query2="CREATE TABLE `$user` (`name` VARCHAR( 32 ) NOT NULL ,`comment` VARCHAR( 255 ) NOT NULL ,`email` VARCHAR( 50 ) NOT NULL ,`site` VARCHAR( 64 ) NOT NULL ,`ip` VARCHAR( 50 ) NOT NULL ,`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY)"; before $username had a ' added in front and back, now i used $user which was just the username without anything added. |
|
#5
|
|||
|
|||
|
cool... glad it all worked out.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Error Creating Table, Someone Help please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|