Jump to content

[SOLVED] You have an error in your SQL syntax;


EXiT

Recommended Posts

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.

 

 

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.