Jump to content

Recommended Posts

this is the error i'm getting "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 '-girl ( `id` INT( 50 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR(' at line 1" when i run the page to create a user. here's the code i'm using, it happens sometimes, but not others, any help?

mysql_connect("$server", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("singlese_messages") or die(mysql_error());
mysql_query("CREATE TABLE $username (
`id` INT( 50 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 75 ) NOT NULL ,
`subject` VARCHAR( 150 ) NOT NULL ,
`message` TEXT NOT NULL ,
`gift` VARCHAR( 50 ) NOT NULL,
`new` VARCHAR( 5 ) NOT NULL ,
`date_created` VARCHAR( 50 ) NOT NULL ,
`date_modified` VARCHAR( 50 ) NOT NULL 
)")  or die(mysql_error());  
mysql_close();

you could enclosed the username for the code to work

mysql_connect("$server", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("singlese_messages") or die(mysql_error());
mysql_query("CREATE TABLE `$username` (
`id` INT( 50 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 75 ) NOT NULL ,
`subject` VARCHAR( 150 ) NOT NULL ,
`message` TEXT NOT NULL ,
`gift` VARCHAR( 50 ) NOT NULL,
`new` VARCHAR( 5 ) NOT NULL ,
`date_created` VARCHAR( 50 ) NOT NULL ,
`date_modified` VARCHAR( 50 ) NOT NULL
)")  or die(mysql_error()); 
mysql_close();

why is it a bad idea to have a separate table for each username, i figured that would be the best way, that way it doesnt have to search through a table full of everyones messages, only that user? how do you think i should make it, cuz this is the only way i know right now??

TEXT is in fact a variation of BLOB. It requires MySQL to split your data, because TEXT and BLOB columns are kept separately from rest of your data, due to their potentially very alrge size. Try to think of some reasonable limit for message size, and just use VARCHAR.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.