Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write an Update query statement in PHP?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I have the following code snippet that I want to have update a specific record in a table via PHP... I keep getting the following error:
Fatal error: Call to undefined function: pq_query()

Any suggestions would be great.


if ($newpasswd == $renewpasswd) {
$query3 = "UPDATE emptable SET password='$newpasswd'
WHERE
(((user_id)='$user_id'))";

$result3 = pq_query ($connection,$query3)
or die("Error in query: $query3.
" . pg_last_error($connection));
 
this means that the php you are using is not with postgresql support enabled, if you are using a package from any kind of distribution you should install a package called php-pgsql or something like that, with the appropriate extension -> dep for debian, rpm for most of the other distros

after installing the package you should enable it in php.ini by adding
extension=pgsql.so
if you are compiling php by your self you can compile the module in the php with adding to ./configure --with-pgsql
for more options you check the documentation

second you should first use pg_connect() to connect to the DB and after that pg_query
 
Thanks for the help. I've corrected the "q"/"g" error and am using the following syntax which works.

if ($newpasswd == $renewpasswd) {
$update = pg_query($connection, "UPDATE emptable SET password='$newpasswd'
WHERE
(((user_id)='$user_id'))");
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top