Jump to content

Archived

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

kurtis

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
what's the query that's giving this error? Post the relevant code snippet as well.

Share this post


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

registration file:
[code]
$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());
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:
[code]
$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());
[/code]

Share this post


Link to post
Share on other sites
While you can use a variation of the UPDATE syntax for inserts, I prefer to use the more conventional approach:

[code]
$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());
[/code]

Share this post


Link to post
Share on other sites
thanks for your help :D but now it says unexpected t_string :( its not my lucky day! lol

Share this post


Link to post
Share on other sites
What Fenway meant of course was

[code]
$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());
[/code]

Share this post


Link to post
Share on other sites
But of course... my bad.

Share this post


Link to post
Share on other sites

×

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.