473,657 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Novice Postgres Query Question

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_m asthead.html");

$db_handle = pg_connect("dbn ame=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_han dle, $query);
if ( pg_numrows($res ult) != 0 ) {
for( $row = 0; $row < 40; $row++ ) {
print '<tr>';
print '<td class="borderce ll" width="5%" ><input
type="checkbox" name="checkbox" value="checkbox "></td>';
print '<td class="borderce ll" 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="borderce ll" width="25%" >' . pg_result(
$result, $row, 'customer' ) . '</td>';
print '<td class="borderce ll" width="40%" >' . pg_result(
$result, $row, 'desription' ). '</td>';
print '<td class="borderce ll" align="center" width="6" >' .
pg_result( $result, $row, 'archive' ) . '</td>';
print '<td class="borderce ll" 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_ha ndle);

?>

</table>

</body>
</html>

May 4 '06 #1
0 1299

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3576
by: OneSolution | last post by:
I need to decide on which database system to use for our company. What is the popular opinion on PostGres vs. MySql? Thanks, Santosh
0
1827
by: Michal Kuna | last post by:
Hi all, I have pg-server 7.4 running on mdk linux. Clients are using a php-gtk based application to communicate with db. I have noticed a very strange behaviour of the postgres server. Sometimes it "hangs" during the query (the query itself is quite simple and does not manipulate a lot of data). The client "freezes" waiting for the server response; and during such "hang" - I tried to execute some simple query on a server machine using...
8
5136
by: wlcna | last post by:
mysql v4.0.16: I had been using mysql with innodb and thought that was fine, until i used it for something requiring a few - perhaps slightly involved - joins, and have now seen the performance become totally unacceptable. I have a query that takes over 35 seconds using mysql and innodb, for reasons that are completely a mystery to me, in a result set consisting of only a handful of items.
7
6649
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had the whole db changed over in 1 hour. Since the upgrade I have been getting the following error message sporadically.
6
2942
by: Prabu Subroto | last post by:
Dear my friends... Usually I use MySQL. Now I have to migrate my database from MySQL to Postgres. I have created a database successfully with "creatdb" and a user account successfully. But I can not access the postgres with pgaccess.
1
1575
by: Esteban Kemp | last post by:
This is the Problem: I'm building a Large DataMart with a big table and I want to improve the performace using aggregates I mean a set of table that store some specific aggregacion of the main table, like materialized views, I know that this feature is not implemented yet in postgres, And I see a interesting article to implementing this using a set of triggers, but I thing the big problem isnot the rate of the updates or the real time...
10
2361
by: Hank | last post by:
We have just recently migrated the data from our Access 2000 backend to Postgres. All forms and reports seem to run correctly but, in many cases, very slowly. We do not want to switch over until we can speed things up. We would like to start implementing Stored Procedures so we can do Server-Side processing. Can anyone recommend a book that would help us learn how to use sprocs or pass-through queries? I apologize if my terminology...
0
2697
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for type oid: "\074\077......";
9
3048
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.