嗨,我有以下代码在一台服务器上运行良好,但在我使用的免费服务器上出现以下错误
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/a9645958/public_html/tteeth/staffslot.php on line 75
我的代码如下:
// 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>";
我很确定问题出在 print f 函数上,因为它要求为 $myrow 中的许多值打印表头,但它还没有得到它的值......但是如果我移动它在选择语句之后,它弄乱了我的其余代码(它不会将时间与数据库中的内容进行比较,并且在下一页上插入数据库时存在问题)