Home  |  Linux  | Mysql  | PHP  | XML
From:Carol Walter Date:Mon Jun 15 14:17:54 2009
Subject:postgres - pg_query works; pg_query_params doesn't
Hello,

I have a php 5 and PostgreSQL 8.3.6. I wrote the original program
using pg_query. Now, I need to replace pg_query with
pg_query_params. I'm having trouble doing so. In this code pg_query
works but pg_query_params doesn't work. The code snippet is as follows:

if ($submit_info2 == "Submit")
{
include "connect_km_tezt.php"; // Connect to database
if ($get_name == Submit)
{
/************* Query using pg_query
*************************************/
/* $query2 = "SELECT \"fName\",\"mName\",\"lName\"
FROM \"tblPeople\"
WHERE \"peopleId\" = '$choose_name'";
$result2 = pg_query($query2) or die("Can't execute
query"); */
/************ Query using pg_query_params
***************************/
$query2 = pg_query_params('SELECT "fName","mName","lName"
FROM "tblPeople"
WHERE "peopleId" = $1', array($choose_name));
/* Process query result */
$rows2 = pg_num_rows($result2);
echo $rows2 . " rows returned. <br />";
while ($row2 = pg_fetch_array($result2))
{
$f_name_new = $row2['fName'];
$m_name_new = $row2['mName'];
$l_name_new = $row2['lName'];
echo "$fName $mName $lName <br />";
}

while (list($fName, $mName, $lName) =
pg_fetch_row($result2))
{
echo "$fName $mName $lName <br />";
}
}
if ($Info2 != "None")
{
echo "<h2>You're entering a " . $Info2 . " for
&nbsp; $f_name_new &nbsp; $m_name_new &nbsp; $l_name_new </h2>
";
}

The error message I get is as follows:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, root@slis.indiana.edu and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.

More information about this error may be available in the server error
log.

Question #1. Do you see why this isn't working.

Question #2. Is there some way I can see the query that is being
passed to the PostgreSQL server.

Question #3. Can I put an "or die" clause on pg_query_params.

I'm not sure how to debug this code.

Thanks,

Carol
Navigate in group php.db at sever news.php.net
Previous Next


Your recent visits
Re: [PHP-DB] ocilogon core dump on Solaris 10 X86 with php-5.2.9 and Oracle 10g
64-bit Linux -- Fatal ... undefined function mysql_connect()
Cannot connect to MySQL
Re: [PHP-DB] php 5.2.9 and Postgres 8.3.7
Re: [PHP-DB] Postgres query failing, not enough info for debugging...



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants