Re: [PHP] SQL Query syntax error... Help?
In the future, to make things easier on yourself, when you get a query syntax error add an "echo $sql;" line right before your query. Almost every time I have a query problem, that solves it. -- Plutarck Should be working on something... ...but forgot what it was. ""Scott VanCaster"" <[EMAIL PROTECTED]> wrote in message 9bd394$ikn$[EMAIL PROTECTED]">news:9bd394$ikn$[EMAIL PROTECTED]... > I've only been trying to learn this stuff for a few days and thought I was > on a roll, but now have run into a problem I don't get at all. In my script > I have the following sql query and am receiving the following error when it > executes "You have an error in your SQL syntax near '' at line 1." > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > updates every record of course :( > > I'm lost here. Thanks for any help. > > $sql ="UPDATE members SET ". > "name='$name', ". > "email='$email', ". > "icq='$icq', ". > "password='$password', ". > "loginid='$loginid', ". > "countryid='$countryid', ". > "gtlogin='$gtlogin', ". > "gtpass='$gtpass', ". > "swirvelogin='$swirvelogin', ". > "swirvepass='$swirvepass' ". > "WHERE id=$id" ; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] SQL Query syntax error... Help?
NEVERMIND! :) -Original Message- From: Scott VanCaster [mailto:[EMAIL PROTECTED]] Sent: Sunday, April 15, 2001 6:05 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] SQL Query syntax error... Help? Nevermind everyone, I'm an idiot :) I had the case wrong. I needed $ID, not $id ! Thanks for the assistance though. Nice to know ya'll are here. Scott ""Scott VanCaster"" <[EMAIL PROTECTED]> wrote in message 9bd394$ikn$[EMAIL PROTECTED]">news:9bd394$ikn$[EMAIL PROTECTED]... > I've only been trying to learn this stuff for a few days and thought I was > on a roll, but now have run into a problem I don't get at all. In my script > I have the following sql query and am receiving the following error when it > executes "You have an error in your SQL syntax near '' at line 1." > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > updates every record of course :( > > I'm lost here. Thanks for any help. > > $sql ="UPDATE members SET ". > "name='$name', ". > "email='$email', ". > "icq='$icq', ". > "password='$password', ". > "loginid='$loginid', ". > "countryid='$countryid', ". > "gtlogin='$gtlogin', ". > "gtpass='$gtpass', ". > "swirvelogin='$swirvelogin', ". > "swirvepass='$swirvepass' ". > "WHERE id=$id" ; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] SQL Query syntax error... Help?
scott, try the entire SQL statement without single quotes around those variables. except for when your setting the WHERE part. Try: $sql ="UPDATE members SET ". "name=$name, ". "email=$email, ". "icq=$icq, ". "password=$password, ". "loginid=$loginid, ". "countryid=$countryid, ". "gtlogin=$gtlogin, ". "gtpass=$gtpass, ". "swirvelogin=$swirvelogin, ". "swirvepass=$swirvepass ". "WHERE id='$id'" ; I could be wrong though, but just my two cents. chris www.variancecreations.net -Original Message- From: Scott VanCaster [mailto:[EMAIL PROTECTED]] Sent: Sunday, April 15, 2001 5:20 PM To: [EMAIL PROTECTED] Subject: [PHP] SQL Query syntax error... Help? I've only been trying to learn this stuff for a few days and thought I was on a roll, but now have run into a problem I don't get at all. In my script I have the following sql query and am receiving the following error when it executes "You have an error in your SQL syntax near '' at line 1." Any idea what my problem is? I removed the WHERE id=$id and it works, but updates every record of course :( I'm lost here. Thanks for any help. $sql ="UPDATE members SET ". "name='$name', ". "email='$email', ". "icq='$icq', ". "password='$password', ". "loginid='$loginid', ". "countryid='$countryid', ". "gtlogin='$gtlogin', ". "gtpass='$gtpass', ". "swirvelogin='$swirvelogin', ". "swirvepass='$swirvepass' ". "WHERE id=$id" ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
Nevermind everyone, I'm an idiot :) I had the case wrong. I needed $ID, not $id ! Thanks for the assistance though. Nice to know ya'll are here. Scott ""Scott VanCaster"" <[EMAIL PROTECTED]> wrote in message 9bd394$ikn$[EMAIL PROTECTED]">news:9bd394$ikn$[EMAIL PROTECTED]... > I've only been trying to learn this stuff for a few days and thought I was > on a roll, but now have run into a problem I don't get at all. In my script > I have the following sql query and am receiving the following error when it > executes "You have an error in your SQL syntax near '' at line 1." > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > updates every record of course :( > > I'm lost here. Thanks for any help. > > $sql ="UPDATE members SET ". > "name='$name', ". > "email='$email', ". > "icq='$icq', ". > "password='$password', ". > "loginid='$loginid', ". > "countryid='$countryid', ". > "gtlogin='$gtlogin', ". > "gtpass='$gtpass', ". > "swirvelogin='$swirvelogin', ". > "swirvepass='$swirvepass' ". > "WHERE id=$id" ; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
Well, I added the echo($id); back in and am just getting $id printed, so it looks like I have another problem :( Now to see if I can find it and figure it out. ""Scott VanCaster"" <[EMAIL PROTECTED]> wrote in message 9bd3pv$qbd$[EMAIL PROTECTED]">news:9bd3pv$qbd$[EMAIL PROTECTED]... > id is the primary key for the table. If I add echo ($id); before the query > it echos a 15, which is correct. Well, it's the right id for the test > person I'm logged into the site as anyway. I'm missing something here :) > > > "Augusto Cesar Castoldi" <[EMAIL PROTECTED]> wrote in message > Pine.A41.4.32.0104151924060.11846-10@marte">news:Pine.A41.4.32.0104151924060.11846-10@marte... > > What do you have in the id variable? > > > > It's contents can be the problem. > > > > regards, > > > > Augusto Cesar Castoldi > > > > On Sun, 15 Apr 2001, Scott VanCaster wrote: > > > > > I've only been trying to learn this stuff for a few days and thought I > was > > > on a roll, but now have run into a problem I don't get at all. In my > script > > > I have the following sql query and am receiving the following error when > it > > > executes "You have an error in your SQL syntax near '' at line 1." > > > > > > Any idea what my problem is? I removed the WHERE id=$id and it works, > but > > > updates every record of course :( > > > > > > I'm lost here. Thanks for any help. > > > > > > $sql ="UPDATE members SET ". > > > "name='$name', ". > > > "email='$email', ". > > > "icq='$icq', ". > > > "password='$password', ". > > > "loginid='$loginid', ". > > > "countryid='$countryid', ". > > > "gtlogin='$gtlogin', ". > > > "gtpass='$gtpass', ". > > > "swirvelogin='$swirvelogin', ". > > > "swirvepass='$swirvepass' ". > > > "WHERE id=$id" ; > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] et > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
I changed $id to '$id' No more error, but nothing updates. Assuming it's because with the single quotes nothing in the table matches? "Felix Kronlage" <[EMAIL PROTECTED]> wrote in message 20010415232649.A11407@mad">news:20010415232649.A11407@mad... > On Sun, Apr 15, 2001 at 04:20:07PM -0500, Scott VanCaster wrote: > > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > > updates every record of course :( > > Have you tried putting the $id in quotes too? > > | WHERE = '$id' > > if that doesn't help, print the sql-statement to STDOUT (e.g. probably to the > browser) and take a look at it, that way it is easier to see where the > error is. > > -fkr > -- > gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0 8A48 0D31 9BD3 D9AC 74D0 > |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE | > |all your base are belong to us | shame on me | fkr@IRCnet | > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
I "think" I tried that. Let me go try that again to be sure. Oh, and what's STDOUT ? I'm just getting started here and haven't even seen that yet :) I can't believe how fast the responses are either. Thanks to all for helping others out so quickly :) "Felix Kronlage" <[EMAIL PROTECTED]> wrote in message 20010415232649.A11407@mad">news:20010415232649.A11407@mad... > On Sun, Apr 15, 2001 at 04:20:07PM -0500, Scott VanCaster wrote: > > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > > updates every record of course :( > > Have you tried putting the $id in quotes too? > > | WHERE = '$id' > > if that doesn't help, print the sql-statement to STDOUT (e.g. probably to the > browser) and take a look at it, that way it is easier to see where the > error is. > > -fkr > -- > gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0 8A48 0D31 9BD3 D9AC 74D0 > |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE | > |all your base are belong to us | shame on me | fkr@IRCnet | > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
id is the primary key for the table. If I add echo ($id); before the query it echos a 15, which is correct. Well, it's the right id for the test person I'm logged into the site as anyway. I'm missing something here :) "Augusto Cesar Castoldi" <[EMAIL PROTECTED]> wrote in message Pine.A41.4.32.0104151924060.11846-10@marte">news:Pine.A41.4.32.0104151924060.11846-10@marte... > What do you have in the id variable? > > It's contents can be the problem. > > regards, > > Augusto Cesar Castoldi > > On Sun, 15 Apr 2001, Scott VanCaster wrote: > > > I've only been trying to learn this stuff for a few days and thought I was > > on a roll, but now have run into a problem I don't get at all. In my script > > I have the following sql query and am receiving the following error when it > > executes "You have an error in your SQL syntax near '' at line 1." > > > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > > updates every record of course :( > > > > I'm lost here. Thanks for any help. > > > > $sql ="UPDATE members SET ". > > "name='$name', ". > > "email='$email', ". > > "icq='$icq', ". > > "password='$password', ". > > "loginid='$loginid', ". > > "countryid='$countryid', ". > > "gtlogin='$gtlogin', ". > > "gtpass='$gtpass', ". > > "swirvelogin='$swirvelogin', ". > > "swirvepass='$swirvepass' ". > > "WHERE id=$id" ; > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
On Sun, Apr 15, 2001 at 04:20:07PM -0500, Scott VanCaster wrote: > Any idea what my problem is? I removed the WHERE id=$id and it works, but > updates every record of course :( Have you tried putting the $id in quotes too? | WHERE = '$id' if that doesn't help, print the sql-statement to STDOUT (e.g. probably to the browser) and take a look at it, that way it is easier to see where the error is. -fkr -- gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0 8A48 0D31 9BD3 D9AC 74D0 |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE | |all your base are belong to us | shame on me | fkr@IRCnet | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query syntax error... Help?
What do you have in the id variable? It's contents can be the problem. regards, Augusto Cesar Castoldi On Sun, 15 Apr 2001, Scott VanCaster wrote: > I've only been trying to learn this stuff for a few days and thought I was > on a roll, but now have run into a problem I don't get at all. In my script > I have the following sql query and am receiving the following error when it > executes "You have an error in your SQL syntax near '' at line 1." > > Any idea what my problem is? I removed the WHERE id=$id and it works, but > updates every record of course :( > > I'm lost here. Thanks for any help. > > $sql ="UPDATE members SET ". > "name='$name', ". > "email='$email', ". > "icq='$icq', ". > "password='$password', ". > "loginid='$loginid', ". > "countryid='$countryid', ". > "gtlogin='$gtlogin', ". > "gtpass='$gtpass', ". > "swirvelogin='$swirvelogin', ". > "swirvepass='$swirvepass' ". > "WHERE id=$id" ; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]