FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


MySQL Error: Timestamp





nikitagupta
I'm getting this error when i used the code below in my server. it works perfectly in my localhost. Could you please rectify the codes?

Error:
[ICODE]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 'Book ( ID INT(10) NOT NULL auto_increment, Timestamp VARCHAR(14) NOT NULL, Name ' at line 1[/ICODE]

This is the MYSQL Code:
Code:
if($create == 'yes') {
            $sql = "CREATE TABLE $tbl_name ( " .
                  "$fld_id INT(10) NOT NULL auto_increment, " .
                  "$fld_timestamp VARCHAR(14) NOT NULL, " .
                  "$fld_name VARCHAR(50), " .
                  "$fld_email VARCHAR(75), " .
                  "$fld_subject VARCHAR(50) NOT NULL, " .
                  "$fld_text TEXT NOT NULL, " .
                  "PRIMARY KEY ($fld_id))";
            if(!mysql_query($sql)) echo '<div class="cssError">' . mysql_error() . '</div>';
            else $table_exists = true;
         }
sonam
Hmmm, I don't see any mistake but maybe you can change the name of field fld_timestamp in fld_time. Yesterday I have problem in php when I try to use $this (OOP) and I got error. When I change name in $this_row the script is working perfect. Because timestamp is SQL syntax maybe this cause problem.

But maybe I don't see something wrong because I haven't time to test it.

Sonam
nikitagupta
i got this error:


Code:
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 'Book ( ID INT(10) NOT NULL auto_increment, VARCHAR(14) NOT NULL, Name VARCHAR(5' at line 1
jmraker
It looks like $fld_timestamp is not defined or has a null value. That would damage the sql statement and cause that error. If that could happen again I'd suggest adding quotes around the php variables in the statement. I like using the ` letter as in

Code:
"`$fld_timestamp` VARCHAR(14) NOT NULL, " . 


because mysql handles the ` letter as a quote and php doesn't

where you'd see `` VARCHAR(14) NOT NULL in the error and it's easier see nothing was put inside those quotes
Related topics
Mysql error!
MySQL error 1604
[solved] Weird mysql error
Suppressing mysql error
[mySQL] Error I cannot Debug
MySql error: Column count doesn't match value count at row 1
Mysql Error
MySQL error
Error connecting to mysql ; please help
Mysql error: Warning: mysql_num_rows():
mysql error
MySQL error
Urgent! MySQL error!
MYSQL Ajax im Installation Error
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.