EXiT Posted May 27, 2008 Share Posted May 27, 2008 Can anyone see anyhing wrong with this? Error: 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 'stats(NULL, user_id, crime_exp, game_exp, money, points, nerve, max_nerve, energy' at line 1 Code: mysql_query("INSERT INTO stats(NULL, user_id, crime_exp, game_exp, money, points, nerve, max_nerve, energy, max_energy, will, max_will, brave, max_brave, hp, max_hp)VALUES I've had a good look at this and can't find anything wrong with it. Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
mushroom Posted May 27, 2008 Share Posted May 27, 2008 "NULL" is a reserved word and can not be used as a field name! Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/#findComment-550914 Share on other sites More sharing options...
EXiT Posted May 27, 2008 Author Share Posted May 27, 2008 Ok here is all the code mysql_query("INSERT INTO users(username, login_name, psword, email, gender) VALUES ('{$username}', '{$username}', SHA1('{$password}'), '{$email}', '{$gender}')", $connect)or die (mysql_error()); $user_id = mysql_insert_id(); mysql_query("INSERT INTO stats(user_id, crime_exp, game_exp, money, points, nerve, max_nerve, energy, max_energy, will, max_will, brave, max_brave, hp, max_hp)VALUES( '{$user_id}', 50, 50, 0, 0, 10, 10, 100, 100, 600, 600, 10, 10, 250, 250)", $connect)or die (mysql_error()); And the table is: CREATE TABLE `stats` ( `stats_id` int(10) unsigned NOT NULL auto_increment, `user_id` int(10) unsigned NOT NULL, `crime_exp` tinyint(4) NOT NULL, `game_exp` tinyint(4) NOT NULL, `money` int(11) NOT NULL, `points` int(10) NOT NULL, `nerve` smallint(6) NOT NULL, `max_nerve` smallint(6) NOT NULL, `energy` smallint(6) NOT NULL, `max_energy` smallint(6) NOT NULL, `will` smallint(6) NOT NULL, `max_will` smallint(6) NOT NULL, `brave` smallint(6) NOT NULL, `max_brave` smallint(6) NOT NULL, `hp` int(11) NOT NULL, `max_hp` int(11) NOT NULL, PRIMARY KEY (`stats_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Ive took out the NULL but it still doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/#findComment-550922 Share on other sites More sharing options...
EXiT Posted May 27, 2008 Author Share Posted May 27, 2008 Is Power a reserved word? Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/#findComment-550939 Share on other sites More sharing options...
mushroom Posted May 27, 2008 Share Posted May 27, 2008 Is Power a reserved word? Have a look http://www.htmlite.com/mysql002a.php Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/#findComment-551093 Share on other sites More sharing options...
AndyB Posted May 27, 2008 Share Posted May 27, 2008 if I create the table named stats with your create query, it works. if I try this query (same as yours), it works. INSERT INTO stats(stats_id,user_id, crime_exp, game_exp, money, points, nerve, max_nerve, energy, max_energy, will, max_will, brave, max_brave, hp, max_hp)VALUES( '','{$user_id}', 50, 50, 0, 0, 10, 10, 100, 100, 600, 600, 10, 10, 250, 250); Are you sure you are testing the right version of your script? Quote Link to comment https://forums.phpfreaks.com/topic/107481-solved-you-have-an-error-in-your-sql-syntax/#findComment-551198 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.