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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!