Page 1 of 1

PHP - MySQL to PostgresSQL

Posted: Thu Jan 05, 2006 9:48 pm
by thcc2
hi all,

I'm developing php search function using the PostgresSQL database,

this is my code where error occur.

Code: Select all

while ($result = pg_fetch_array($sqlcmd,0))
    {
    		$max++;
    }
it igves the error of :
Warning: pg_fetch_array(): supplied argument is not a valid PostgreSQL result resource in
thks in advance.

Posted: Thu Jan 05, 2006 10:00 pm
by feyd
I'm going to guess $sqlcmd is not the result resource returned from pg_query(), pg_query_params(), or pg_execute()

Posted: Thu Jan 05, 2006 10:13 pm
by thcc2
feyd wrote:I'm going to guess $sqlcmd is not the result resource returned from pg_query(), pg_query_params(), or pg_execute()
thks for ur reply, i think i have not execute the query, so i have make some changes on my code

Code: Select all

$max = 0;
$sqlcmd = "select display_name, numb, level from book " .
			"where display_name like 'display_name%'"; 
    $result = pg_query($dbconn, $sqlcmd);
    while ($arr = pg_fetch_array($result,0))
    {
    		$max++;
    }
but it gives me an error of :
Warning: pg_fetch_array(): Unable to jump to row 0 on PostgreSQL result index 4 in
thks in advance

Posted: Thu Jan 05, 2006 10:23 pm
by feyd
Try not using the row argument if you're running php 4.1.0 or higher.

Posted: Thu Jan 05, 2006 10:28 pm
by thcc2
feyd wrote:Try not using the row argument if you're running php 4.1.0 or higher.
ok, thks :D