Page 1 of 1

could someone help me, whats wrong with this syntax?

Posted: Thu Jul 04, 2002 6:42 am
by zerodegreeburn
k here goes, inputing info into a database

Code: Select all

$DB_site->query("UPDATE їIGNORE] ftpdata (threadid,ip,path,port,pass,user) VALUES('$threadid','".addslashes($ip)."','".addslashes($path)."','".addslashes($port)."','".addslashes($pass)."','".addslashes($user)."')");
threadid, obviously is already there, the data is being EDITED, this is what i get

Invalid SQL: UPDATE [REPLACE | IGNORE] ftpdata
mysql error: You have an error in your SQL syntax near '[REPLACE | IGNORE] ftpdata at line 1

mysql error number: 1064



i used [ignore] because it's supposed to ignore the fact that threadid has the same value, and therefore be a-okay, when i dont use ignore this is what i get:

Invalid SQL: UPDATE ftpdata (threadid,ip,path,port,pass,user) VALUES('****','****','****','****','****','****')
mysql error: You have an error in your SQL syntax near '(threadid,ip,path,port,pass,user) VALUES('****','****' at line 1


plz guru HELP :(

Posted: Thu Jul 04, 2002 6:51 am
by zerodegreeburn
thx for the fasssst replyt

unfortunately:

Invalid SQL: UPDATE IGNORE ftpdata (threadid,ip,path,port,pass,user) VALUES('****','****','','****','****','****')
mysql error: You have an error in your SQL syntax near '(threadid,ip,path,port,pass,user) VALUES('****','****','','****','****' at line 1

mysql error number: 1064

Posted: Thu Jul 04, 2002 6:53 am
by zerodegreeburn
hey thats weird, where did waynes reply go?

lol

Posted: Thu Jul 04, 2002 6:55 am
by Wayne
try this:

Code: Select all

$DB_site->query("UPDATE IGNORE ftpdata SET
threadid='$threadid',
ip='".addslashes($ip)."',
path='".addslashes($path)."',
port='".addslashes($port)."',
pass='".addslashes($pass)."',
user='".addslashes($user)."'
");

Posted: Thu Jul 04, 2002 6:58 am
by zerodegreeburn
sweeeeet dude it works

i cant believe it

:D


thx thx thx,, contact me anytime you need ANYTHING

Posted: Thu Jul 04, 2002 7:04 am
by twigletmac
Check out the documentation for UPDATE as you're confusing the UPDATE syntax with INSERT syntax. Try something like:

Code: Select all

UPDATE ftpdata SET threadid='$threadid', ip='".addslashes($ip)."', path='".addslashes($path)."', port='".addslashes($port)."', pass='".addslashes($pass)."', user='".addslashes($user)."'";
If you are trying to update every single row in your database with that information. If you want to update a single row that already exists try:

Code: Select all

UPDATE ftpdata SET ip='".addslashes($ip)."', path='".addslashes($path)."', port='".addslashes($port)."', pass='".addslashes($pass)."', user='".addslashes($user)."' WHERE threadid='$threadid'";
If you are trying to add a new row to the table use INSERT:

Code: Select all

INSERT INTO ftpdata (threadid, ip, path, port, pass, user) VALUES('$threadid', '".addslashes($ip)."', '".addslashes($path)."', '".addslashes($port)."', '".addslashes($pass)."', '".addslashes($user)."')";
I thought I'd post this even though Wayne posted a solution as I spent time typing it :) and it may explain the problem to other people.

Mac

Posted: Thu Jul 04, 2002 7:05 am
by zerodegreeburn
thanks very much to both of you for your quick and speedy responses to the problem.

ah i sound all growned up

;)

damn sweet dude finally it works ! :D



this is THE best support board there is