Query problems with PostgreSQL



Hi,

I'm having intermittent problems with queries from my php script to a
postgresql database.

I have a form where I can enter a search query - for instance a last
name. This leads to a results page with a brief bit of information
about each of the matching results. From there, I can click a link
associated with any of the results which takes me to a page with all of
the details. Pretty standard stuff.

Problem I'm having is that for some of the results, when I click the
link to go to the full details page, no information is returned by the
script. I basically end up with my html template & no data populated.
For the majority of items, things work just fine.

One thing I've noticed is that it seems to be reproducable - that is,
for example item 5123 always fails to return any results on the full
details page.

From my Postgres box (windows 2003), I can run the exact same query as
from my PHP script (with item id 5123) & it returns the data.

So what could the problem possibly be?

I thought that perhaps it was a load issue on the server - couldn't
answer the query, but the fact that it's reproducible seems to nix that
idea. Also, that Postgres box has 3.5 GB of RAM & we're talking about
a test system at this point - I'm the only one using it.

Code for my first search results page (basic info & hyperlinks) looks
like this ($name_last is the variable passed from the search form):

$connection=pg_connect("host=10.10.10.2 port=5432 dbname=db1
user=dbuser password=password");

$myresult = pg_exec($connection, "SELECT identification_no, name_last
, name_first, name_middle FROM public.j_identification WHERE name_last
~*
'$name_last'");


The code for my detailed results page looks like this:

$connection = pg_connect("host=10.10.10.2 port=5432 dbname=db1
user=dbuser password=password");

$myresult = pg_exec($connection, "SELECT * FROM
public.archived_with_photos
WHERE identification_no = '$id_no'");


'public.archived_with_photos' is a view defined on the postgresql
server.

I can run the query

SELECT * FROM public.archived_with_photos WHERE identification_no =
'5123';

and it returns all of the associated data from the database... whereby
the exact same query failed with the PHP script.

Any help or ideas greatly appreciated!

.



Relevant Pages

  • Re: Query problems with PostgreSQL
    ... postgresql database. ... I have a form where I can enter a search query - for instance a last ... 'public.archived_with_photos' is a view defined on the postgresql ... the exact same query failed with the PHP script. ...
    (comp.lang.php)
  • postgresql and binary data
    ... I have some postgresql database that stores binary data. ... Also I have php script that allows users download these binaries via their web browser. ... That stuff was running on ubuntu 7.10 with postgresql 8.2 and most recent php version. ...
    (comp.lang.php)
  • [UNIX] SQL Inject in ProFTPD Login against PostgreSQL Using mod_sql
    ... A SQL Inject exists in <http://proftpd.linux.co.uk/> ProFTPD server using ... the mod_sql module to authenticate against PostgreSQL database server. ... mod_sql_postgres is used to authenticate users doing a query to PostgreSQL ... print STDOUT $line; ...
    (Securiteam)
  • Re: mysql_query(): supplied argument is not a valid MySQL-Link resource
    ... When I had my first attempt at using functions in a PHP script I had similar ... I got round it by passing all variables outside the function into ... > close a connection to the database very time I run a query. ...
    (comp.lang.php)
  • Re: PostgreSQL and Firebird comparison via digg
    ... Do you know if using PostgreSQL a query or connection can have a priority set, so it can run quicker than other queries? ... in a POS system the reporting queries should have lower priority than the generated invoices insert queries. ... I know a lot of people are basing this whole threading thing on when PostgreSQL only ran on windows via cygwin Unix emulation and yes that did suck, but that is a thing of the way way past. ...
    (borland.public.delphi.non-technical)