could someone help me, whats wrong with this syntax?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

could someone help me, whats wrong with this syntax?

Post 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 :(
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

Post 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
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

Post by zerodegreeburn »

hey thats weird, where did waynes reply go?

lol
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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)."'
");
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

Post by zerodegreeburn »

sweeeeet dude it works

i cant believe it

:D


thx thx thx,, contact me anytime you need ANYTHING
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

Post 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
Post Reply