Query working in db, but not in php
Posted: Wed Sep 07, 2005 2:08 pm
This is the query string, which looks okay to me.
When executed in phpmyadmin, it returnd records as expected.
When executed by this following code, it returns zero records.
(I did a "echo $Query" to be sure the query string is correct, and it is.)
The other two constructs result in similar query strings and they return results just fine
from the same table, so database is selected properly and all that.
Any help from any of you gurus?
Code: Select all
SELECT id,Sid FROM Reports WHERE Stat>1 AND Stat<4 ORDER BY NumbrWhen executed by this following code, it returns zero records.
Code: Select all
$Query = "SELECT id,Sid FROM Reports WHERE Stat>1"; // all reviewed reports
if ($_SESSION['Method'] > 2)
$Query .= " AND YEAR(Date)=" . $_SESSION['Cyr'] . " AND MONTH(Date)=" . $_SESSION['Cmth'];
else if ($_SESSION['Method'] > 1)
$Query .= " AND Sid=" . $_SESSION['Cstr']; // for selected store
else $Query .= " AND Stat<4"; // not previously viewed
$Query .= " ORDER BY Numbr";
$Result = mysql_query($Query, $Link);
while ($row = mysql_fetch_array($Result))
// etcThe other two constructs result in similar query strings and they return results just fine
from the same table, so database is selected properly and all that.
Any help from any of you gurus?