Carol Walter wrote:
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
$f_name_new $m_name_new $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@xxxxxxxxxxxxxxxx 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
pg_error() will tell you why. more then likely you should test the valid
resource coming from the pg_connect function.
--
Jas
"Tomorrow isn't promised so we live for today"
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php