Page 1 of 1

Update in Postgres

Posted: Wed Aug 28, 2002 5:04 am
by Love_Daddy
Hi Guys,

I'm trying to write an update query in PHP using progres..

$sql="UPDATE users SET
name='$name',
surname='$surname',
tel_no='$telno',
cel_no=$celno
WHERE emp_no=$empno";
$results=pg_exec($connection,$sql);

But it doesn't work.
What would be a problem?

I get this msg:

Warning: PostgreSQL query failed: ERROR: parser:
parse error at or near "" in /var/www/html/shakanet/update.php on line 20
Connection to Table not established!

Of which line 20 is:
$results=pg_exec($connection,$sql);

Thanks

My situation

Posted: Wed Aug 28, 2002 5:07 am
by Love_Daddy
I'm trying to update my user table, for more than 1 field.

Posted: Wed Aug 28, 2002 8:01 am
by nielsene
Have you tried echo'ing out $sql before passing it to pg_exec to make sure its the right query? Have you established the connection with pg_connect/pg_pconnect at some point in your program?

Posted: Wed Aug 28, 2002 9:41 am
by Love_Daddy
I'll try it and let you know.

Thanks

Posted: Wed Aug 28, 2002 2:46 pm
by haagen
If i don't remember wrong postgres behaves a bit odd with single- and double quotes (' and "). Try to change your ' into " and see if it still complaints.

Posted: Wed Aug 28, 2002 2:56 pm
by nielsene
PostGreSQL wants single quotes (')s to surround string literals in the query string, as the poster showed in code.

Posted: Wed Aug 28, 2002 3:21 pm
by haagen
Then I remembered wrong. I allways mix those damn quotes. :x