Jump to content


Photo

You have an error in your SQL syntax.......


  • Please log in to reply
8 replies to this topic

#1 kurtis

kurtis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 August 2006 - 06:49 PM

yes its the annoying "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 '' at line 1" error!
im follwing the user system tutorial but made my own registration page becuase i couldnt get the other one working so i made my own which seems to promise more but i still get this error and i dont know why  ???
anyone got any ideas?
thanks

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 03 August 2006 - 07:01 PM

what's the query that's giving this error? Post the relevant code snippet as well.

#3 kurtis

kurtis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 August 2006 - 07:23 PM

db.php:
<?
$link = mysql_CONNECT(localhost,root);
mysql_select_db(dijeridooo);
if (!$link) {
	die('could not connect:' . mysql_error());
}
echo 'connection succesful';
?>
(i added the echo just to make sure it was connecting)

registration file:
$query = mysql_query('INSERT INTO users VALUES(id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate') or die (mysql_error());


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 August 2006 - 07:47 PM

Yeah, that makes no sense... those aren't values -- string literals -- they're field names.  And where is the column list?  I'm confused, and so is the parser.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 kurtis

kurtis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 August 2006 - 08:05 PM

ye i thought that :S i rote it originally i had a few errors so i asked my mate for advice(hes been doing it longer than me) n he just messed round with the connection till it came up with this error and the he didnt know what to do :S this is the one i had before:
$query = mysql_query('INSERT INTO users VALUES(id=$id, username=$username, encryptpass=$encryptpass, password=$password, name=$name, prov=$prov, style=$style, hist=$hist, infl=$infl, open=$open, webs=$webs, email=$email, signupdate=now()') or die (mysql_error());


#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 August 2006 - 08:32 PM

While you can use a variation of the UPDATE syntax for inserts, I prefer to use the more conventional approach:

$query = mysql_query('INSERT INTO users (id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate ) VALUES('$id', '$username', '$encryptpass', '$password', '$name', '$prov', '$style', '$hist', '$infl', '$open', '$webs', '$email', now()) or die (mysql_error());


Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 kurtis

kurtis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 August 2006 - 09:37 PM

thanks for your help :D but now it says unexpected t_string :( its not my lucky day! lol

#8 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 03 August 2006 - 09:48 PM

What Fenway meant of course was

$query = mysql_query("INSERT INTO users (id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate ) VALUES('$id', '$username', '$encryptpass', '$password', '$name', '$prov', '$style', '$hist', '$infl', '$open', '$webs', '$email', now()") or die (mysql_error());

Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#9 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 04 August 2006 - 12:36 AM

But of course... my bad.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users