下面是我的代碼,我試着用var_dumps調試它。var_dump($ insertion)返回,這意味着查詢插入到數據庫中,但由於某種原因,當我想要查看mysql_num_rows是否正在完成其作業並且它返回FALSE並顯示標題警告消息時,我會收到警告消息。以下是我的短直接代碼警告:mysql_num_rows():提供的參數不是第21行的有效MySQL結果資源
<?php
require'sensdb.php';
if (sensdb_connect()) {
$select = "SELECT SubGroupID from STx WHERE GroupID = '39'AND Status ='Provisioned'";
$result = mysql_query($select);
$result_count = mysql_num_rows($result);
if($result_count > 0)
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if($row['SubGroupID'] != 123) {
$insert = "INSERT INTO Routes (SubGroupID,GroupID,URL) VALUES (".$row['SubGroupID'].",39,'mailto://[email protected]')";
$insertion = mysql_query($insert);
$insertion_count = mysql_num_rows($insertion); var_dump($insertion_count);
$select_route_id = "SELECT RouteID FROM Routes WHERE SubGroupID =".$row['SubGroupID']." AND GroupID = 39";
$result_route_id = mysql_query($select_route_id);
$result_route_count = mysql_num_rows($result_route_id);
if($insertion_count > 0) {
if($result_route_count > 0) {
$row_route = mysql_fetch_array($result_route_id,MYSQL_ASSOC);
$update = "UPDATE STx SET RouteID =".$row_route['RouteID']." WHERE SubGroupID =".$row['SubGroupID']."";
var_dump($update);
}
}
}
}
}
}
您的查詢中有錯誤。您需要進行適當的錯誤檢查才能捕獲這些問題並進行調試。 http://www.php.net/mysql_error – 2013-02-11 23:15:48
@Pekka웃他的SQL可能有錯誤,但這不是原因。 – 2013-02-11 23:18:28