Hi,
I am new to php.I have a php file which compares tables and fetches data from the database.But I am getting an error.(Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\wamp\www\rep28old\camdisp1.php on line 68)I have given the coding below.Pl help me to proceed further.
Thanks in advance.
<?php
session_start(); // start up your PHP session!
?>
<body>
<?php
mysql_connect("localhost","root","") or die('cannot connect'.mysql_error());
mysql_select_db("dialer");
?>
<table>
<form method=post action='<?php $SERVER[PHP_SELF] ?>' name=condisp>
From Date--------
To Date---------
Campaign---------
<?
$res = mysql_query("show tables");
$tab=$GET['tab'];
echo "<select name=tablename value= size=15>";
echo "<option value='All' Selected>All</option>";
while($res1= mysql_fetch_row($res))
{
if($res1[0]==@$tab){
echo "<option selected value='$tab'>$tab</option>"."<BR>";
}else{
echo "<option value='$res1[0]'>$res1[0]</option>";}
}
echo "</select>";
?>
</td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <input type=submit name=submit value=Report></td></tr>
</form>
</table>
<?php
$tdate2 = $POST{'tdate'};
$fdate2 = $POST{'fdate'};
$submit = $_POST{'submit'};
$SESSION['fdate']=$fdate;
$SESSION['tdate']=$tdate;
$tname = trim($POST{tablename});
$fdate = trim($POST{fdate});
$tdate = trim($_POST{tdate});
if($submit == 'Report')
{
if($tname == 'All'){
$res =mysql_query("SELECT count( * ) , a.disposition, b.disp_name FROM $tname a, reports.disposition b WHERE a.disposition = b.disp_code and date(lastupdated) >='$fdate' and date(lastupdated) <= '$tdate' GROUP BY a.disposition");
}else{
$res = mysql_query("SELECT count( * ) , a.disposition, b.disp_name FROM $tname a, reports.disposition b WHERE a.disposition = b.disp_code and date(lastupdated) >='$fdate' and date(lastupdated) <= '$tdate' and tablename = '$tname' GROUP BY a.disposition");}
$r= mysql_query("select agent from $tname");
$num = mysql_num_rows($r);
$num1 = mysql_num_rows($res);
echo "<table width=100% cellspacing=0 cellpadding =0 border=1>
<tr><td>Disposition Report for</td><td> $tname [Records : $num]";
if($ddate <> 'ALL'){
<tr class=h4><td>Disposition Name</td><td align=center>Disposition ID</td><td align=center>Count</td></tr>";
if ($num1 =="0")
{
echo "<tr align=left><td>No Records Dialed</td><td align=center></td><td align=center></td></tr>";
}else{
while(list($count,$d_id,$d_name,$a_name) = mysql_fetch_row($res))
{
echo "<tr align=left><td>$d_name</td><td align=center>$d_id</td><td align=center>$count</td></tr>";
}
}
echo "</table>";
}
else{
}
echo "</table>";
?>
</form></table>
</div><!-- end page -->
</body>
</html>