What am I doing wrong in this script?
Posted: Fri Nov 05, 2010 8:49 pm
I've tried running this same query in phpmyadmin and it turns out great but I'm not as fortunate when I run it in php.
So, I figured maybe it's in my php code because the query works fine.
This is the error that it returns.
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\reports.php on line 56
//////////////////////////////////////////
//$date1 and $date2 contains the right values, i checked
$dquery="select distinct `vessel` as `vessel` from `bill` where `dateissue` >= ' ".$date1." ' and `dateissue` <= '".$date2." ' ";
$dres=mysql_query($dquery) or die(mysql_error());
while($drow=mysql_fetch_array($dres)){
$vessel=$drow['vessel'];
echo $vessel;
}
So, I figured maybe it's in my php code because the query works fine.
This is the error that it returns.
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\reports.php on line 56
//////////////////////////////////////////
//$date1 and $date2 contains the right values, i checked
$dquery="select distinct `vessel` as `vessel` from `bill` where `dateissue` >= ' ".$date1." ' and `dateissue` <= '".$date2." ' ";
$dres=mysql_query($dquery) or die(mysql_error());
while($drow=mysql_fetch_array($dres)){
$vessel=$drow['vessel'];
echo $vessel;
}