You are here: Novice Postgres Query Question « PHP Programming Language « IT news, forums, messages
Novice Postgres Query Question

Posted by Lee Blevins on 05/05/06 02:32

I'm trying to query a postgresql database with PHP.

I am having a problem when using a WHERE. It works without the WHERE.

Example:

$query = "SELECT job_number, customer, desription, archive, date_opened,
job_status FROM jobs WHERE job_status='In Progress' ";


Returns this error in browser:


Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 23

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 24

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 24

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 25

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 26

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 27

Warning: pg_result(): Unable to jump to row 28 on PostgreSQL result index 7
in /usr/local/apache2/htdocs/jobs.html on line 28


The full code I'm using is listed below: (with bad indents from newsreader)



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Jobs Display</title>
</head>
<body>
<div id="content" class="feature" >
<table width="800" border="0">

<?php
include("jobs_masthead.html");

$db_handle = pg_connect("dbname=test user=postgres password=1234");

if( $db_handle ) {
$query = "SELECT job_number, customer, desription, archive,
date_opened, job_status FROM jobs WHERE job_status='In Progress' ";
$result = pg_exec($db_handle, $query);
if ( pg_numrows($result) != 0 ) {
for( $row = 0; $row < 40; $row++ ) {
print '<tr>';
print '<td class="bordercell" width="5%" ><input
type="checkbox" name="checkbox" value="checkbox"></td>';
print '<td class="bordercell" width="10%" >' . substr(
pg_result( $result, $row, 'job_number'), 0, 2) . "-" .
substr( pg_result( $result, $row, 'job_number'), 3, 4) . "-"
.. substr( pg_result( $result, $row, 'job_number'), 7, 2) . '</td>';
print '<td class="bordercell" width="25%" >' . pg_result(
$result, $row, 'customer' ) . '</td>';
print '<td class="bordercell" width="40%" >' . pg_result(
$result, $row, 'desription' ). '</td>';
print '<td class="bordercell" align="center" width="6" >' .
pg_result( $result, $row, 'archive' ) . '</td>';
print '<td class="bordercell" width="6" >' . pg_result(
$result, $row, 'date_opened' ) . '</td>';
print '<tr>';
}
} else {
print "There is no result.<br>";
}
} else {
print "No db_handle was made.<br>";
}
// print "Closing the db_handle.<br>";
pg_close($db_handle);

?>

</table>

</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация