Gossamer Forum
Home : General : Perl Programming :

PHP and PostgreSQL problem!!!

Quote Reply
PHP and PostgreSQL problem!!!
Hi!

I'm pretty new in a PostgreSQL.
Any ideas what's wrong with that?

<?php
if(pg_num_rows($result)!=0) {$NNN=pg_Result($result,0,"hits")+1; $result = pg_exec($conn, "update adviews set hits=$NNN where adid=$id");}
else {$NNN=1;$result = pg_exec($conn, "insert into adviews values ($id,1)");}
pg_close($conn);
echo "<font face=\"Arial\" size=\"1\">Your AD has been viewed by $NNN people</font>";
?>

Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /var/www/development/photos.php on line 60

Warning: pg_exec(): supplied argument is not a valid PostgreSQL link resource in /var/www/development/photos.php on line 61

Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /var/www/development/photos.php on line 62
Your AD has been viewed by 1 people

Thank you
Quote Reply
Re: [doom] PHP and PostgreSQL problem!!! In reply to
I'm not sure if there is such a function for PostGreSQL, but in MySQL (with PHP), you can us;

Code:
$error = mysql_error();
if ($error) { echo "There was an error with your SQL. Reported as: $error"; exit; }

From what I can see, you would use pg_last_error() for PostgreSQL

Here is the official PHP documentation for it;

http://uk.php.net/manual/en/ref.pgsql.php

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates