Hi I have the following code which works fine on one server but I get the following error on a free server I have used
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/a9645958/public_html/tteeth/staffslot.php on line 75
my code is as follows:
// Starting of top line showing name of the day's slots
echo "<form method='post' name='time' action='timeinsert.php'>
<table align='center' width='380' border='1'>
<tr>
<th>Select</th>
<th>Appointment Times</th>
</tr>";
// Starting of the slots
for($i=0;$i<=31;$i++){ // this shows 32 x 15 minute slots from 9:00am - 17:00pm
$shr=9+floor($i/4); //calculates the start hour of a slot
$smin=($i%4)*15; //calculates the start minutes of a slot
$time=mktime($shr,$smin,00,0,0,0); //creates full php time from hours and minutes above
$displayTime2=date("H:i:s",$time); // creates correct time format for MySQL database hrs, mins, seconds
$pagetime = date("H:i a", strtotime($displayTime2)); //converts the time to just hours and minutes
$timenow = date('H:i'); // get's the current time
$chosendate = date(mktime(0,0,0,$month,$day,$year)); // converts the date picked to php time (seconds since 01 01 1971)
$todayDate = date(mktime()); // converts today's date to php time so it can be compared with the chosen date
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td>%s</td></tr>\n",
$myrow[0]);
}
$result=mysql_query("SELECT * FROM appointment where Appointment_Time='$displayTime2' AND Appointment_Date='$insertdate' AND Practice_ID='$practice'");
$myrow = mysql_fetch_row($result);
if($pagetime<$timenow AND $chosendate<$todayDate) //if the display time is less than the time now, and the date is less than todays date
{ //do not display a row
}
elseif($myrow)// if the values in the database match the row slot time
{
echo "<td></td><td align='center'>$pagetime</td>";//just display the slot as a time
}
else
{
echo "<td align='center'><input type='checkbox' name='$displayTime2' onclick='KeepCount()'></td>
<td align='center'>$pagetime</td>";
}
echo "</td></tr>";
}
echo "</table><br>
<input type='submit' value='Submit'>
</form>";
I'm pretty cofident that the problem is with the print f function because it asks to print the table header for however many values there are in $myrow, but it hasn't got the valuue of it yet...but if I move it to after the select statement, it messes up the rest of my code (it doesnt compare the time with whats in the db, and there are problems inserting into the db on the following page)