Page 2 of 2
Posted: Fri Jul 02, 2004 12:00 am
by deniscyriac
It's the same problem, the query is missing when we refresh the page
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Reactor\htdocs\timetracker\report.php on line 17
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Reactor\htdocs\timetracker\report.php on line 20
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Reactor\htdocs\timetracker\report.php on line 21
Posted: Fri Jul 02, 2004 12:10 am
by feyd
well. the way it's written now, you need $report set when the script is run. So is it set for the first page?
Posted: Fri Jul 02, 2004 12:17 am
by deniscyriac
Could you please check this code.
I'm parsing the " $report " as a string from flash....
thanks,
Denis
Code: Select all
<?
$hostname = "localhost";
$username = "";
$password = "";
$dbName = "timetracker";
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect");
@MYSQL_SELECT_DB("$dbName") OR DIE("Unable to select database");
// $report = "SELECT DATE_FORMAT(b.date_txt, ''%m-%d-%Y'' ) AS ''Date'' ,b.Team, a.username AS ''Name'', b.Activity, b.time FROM tracker b, users a where a.pkecode = b.pkecode ORDER BY b.date_txt";
if(!isset($start)) $start = 0;
$reports = $report;
$q= stripslashes($reports);
$query = $q. " LIMIT $start, 40";
$report1 = $q;
$query1 = $report1;
$result1 = mysql_query($query1);
$numrows = mysql_num_rows($result1);
$result = mysql_query($query);
$total_rows = mysql_num_rows($result);
$row = mysql_fetch_row($result);
$total_cols = count($row);
if (!$total_rows) {
print "<HTML><title>Reports</title><FONT size='4' color='#000000' face='Verdana, Arial, Helvetica, sans-serif'><b>No report found! Please search again.... </b></FONT></BODY></HTML>";
return;
}
print "<HTML><title>Reports</title><BODY text="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin='0' marginheight='0'>";
print "<table width='500' border='0' cellspacing='0' cellpadding='3' align='center'> ";
print "<tr bgcolor="#61ABD0"><td colspan=$total_cols align=center><FONT size='3' color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif'><b>$pagetitle</b></FONT></td></tr>";
print "<tr bgcolor="#A8D2F2">";
$count = mysql_num_fields($result);
for ($i = 0; $i < $count; $i++) {
print "<td><FONT size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>";
$header = mysql_field_name($result, $i)."\t";
print $header;
print "</b></FONT></td>";
}
print "</tr>";
print "<tr>";
$i=0;
while($i < $total_cols){
print "<td><FONT size='1' face='Verdana, Arial, Helvetica, sans-serif'>";
print $row[$i];
print "</FONT></td>";
$i++;
}
print "</tr>";
$j = 1;
while($row = mysql_fetch_row ($result)) {
$j++;
$i = 0;
if ($j%2 == 0) {
print "<tr bgcolor="#EAF3FB">";
}else{
print "<tr bgcolor="#FFFFFF">";
}
while($i < $total_cols){
print "<td ><FONT size='1' face='Verdana, Arial, Helvetica, sans-serif'>";
print $row[$i];
print "</FONT></td>";
$i++;
}
print "</tr>";
}
print "<tr><td> ";
print "<tr bgcolor="#A8D2F2"><td colspan=$total_cols align=center>";
print "<table width='100%' border='0' cellspacing='0' cellpadding='2' align='center'> ";
print "<tr width='50%'><td align='left' width='25%'><FONT size='2' color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif'>";
if($start > 0)
echo "<< <a href="" . $PHP_SELF . "?start=" . ($start - 40) ."&report=".$query1."">Previous</a>";
print "</FONT></td><td align='center' width='50%' height='20'><FONT size='2' color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif'>";
print "<a href="javascript:void(window.print())"><img src="images\printicon.gif" border='0' alt='print'></a>";
print "</FONT></td><td align='right' width='25%' height='20'><FONT size='2' color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif'>";
if($numrows > ($start + 40))
echo "<a href="" . $PHP_SELF . "?start=" . ($start + 40) ."&report=".$query1."">Next</a> >>";
print "</FONT></td></tr>";
print "</TABLE>";
print "</td></tr>";
print "</TABLE></BODY></HTML>";
?>
feyd | Please use Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Fri Jul 02, 2004 12:28 am
by feyd
$report isn't set inside the context of the file, for at least the first pass.
Posted: Fri Jul 02, 2004 12:30 am
by deniscyriac
so what is the solution
Posted: Fri Jul 02, 2004 12:32 am
by feyd
either define a default search, if you have one (highly suggested) or always call the script with ?report=XXX .. you should be able to call the script without any arguments though (just so someone typing in the url doesn't encounter errors)