PHP - MySQL to PostgresSQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

PHP - MySQL to PostgresSQL

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm going to guess $sqlcmd is not the result resource returned from pg_query(), pg_query_params(), or pg_execute()
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Try not using the row argument if you're running php 4.1.0 or higher.
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

feyd wrote:Try not using the row argument if you're running php 4.1.0 or higher.
ok, thks :D
Post Reply