RE: [PHP] Strange coding bug

From: Pat Hanna (phanna_at_email.unc.edu)
Date: 01/05/04


To: "'Brad Pauly'" <brad@robinsontech.com>
Date: Mon, 5 Jan 2004 15:30:25 -0500

I have tried printing out the query and got the exact same thing on both
pages. The only relevent code is the code I included. The $item_number
gets passed to both pages exactly the same. The query comes up no
different on both pages. It is accessing the exact same product and yet
it will not get a hit.

Pat

-----Original Message-----
From: Brad Pauly [mailto:brad@robinsontech.com]
Sent: Monday, January 05, 2004 3:28 PM
To: Pat Hanna
Cc: 'php help'
Subject: Re: [PHP] Strange coding bug

On Mon, 2004-01-05 at 12:59, Pat Hanna wrote:
> I cannot seem to find the problem in my code. I have two pages. Both
> need to select a product from a database. The first page works fine,
> the product is found and I use the data in the page. The second one
> does not fetch the product. The code is exactly the same:
>
> $query="SELECT * FROM products WHERE stock_number = '$item_number'";
> $result=mysql_query($query); $row=mysql_fetch_array($result);
>
> When I do 'echo $result;' on the first page, I get the result number.
> But if I do it on the second page I get nothing. Both pages are
> connected to the database and I get no errors in code. I have included

> the full code of each page in the attachment. Item_details.php3 is the

> working page and addtocart.php3 is the one that won't seem to connect.

I think the attachments got removed. Sorting through the source of two
pages is a lot to look through. Maybe you could paste the relevant code
from each of the pages. Specifically, the select statements and where
$item_number comes from or is manipulated. That should help find the
problem. You might also try echoing $query on both pages to make sure
they same query actually is being executed.

- Brad



Relevant Pages

  • Re: [PHP] Re: find (matching) person in other table
    ... than, say, 25 or 50, re-run the query and change the letters matched to 4, ... Well, see, if the match isn't exact, it won't return anything. ... Look at the Levinshtein PHP ... There's a lot of unnecessary work you're making PHP and your database do. ...
    (php.general)
  • RE: [PHP] Strange coding bug
    ... > I have tried printing out the query and got the exact same thing on ... The only relevent code is the code I included. ... It is accessing the exact same ... PHP Security Handbook ...
    (php.general)
  • Re: Database Search Results Are Incorrect
    ... The site link with query ... right results even if my query is exact. ... Karen - I am pulling data from a database management ...
    (microsoft.public.frontpage.client)
  • Re: Subject: modifying SQL criteria in a search for duplicates
    ... It's displaying the exact duplicate records I was looking for, ... I won't need to keep running the query. ...
    (microsoft.public.access.queries)
  • Re: Permutations - 8 columns
    ... We are not allowed to query ... the database directly and exact the information in a tabular form. ... However there are standardised reports which we can use to extract the ...
    (microsoft.public.excel.programming)