Jump to content

[SOLVED] Warning: pg_exec(): supplied argument is not a valid PostgreSQL link resource


Ekate

Recommended Posts

Hello,

I'm getting the following error when I'm running the script:

Warning: pg_exec(): supplied argument is not a valid PostgreSQL link resource

My code:

function getId()
{
	$serial=$this->serial_number;
	$result= pg_exec($db_handle,"select id 
					         from gifts 
						 where serial_number = '$serial';") or die('Query failed.'.pg_last_error()); ///Error message
                                                                                                                                                        ///points to this line
	if (pg_numrows($result) == 1)
	{return pg_result($result,0,'id');}else {return 'Error';};
}

 

Could you please point me why?

Thank you,

BR,

Ekate

Link to comment
Share on other sites

Thanks a lot,

I just have to move the project from MySQL to Postgre...

One more stupid question if you don't mind,

if I have class and a lot of functions, and every funcrion looks like this getId, will I have to declare this variable $db_handle as global for every function, or there is another smart way?

 

Thank you,

BR,

Ekate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.