以下是我的代码,我尝试用var_dump调试它.var_dump($ insertion)返回,这意味着查询插入数据库但由于某种原因,我会在收到警告消息时我想知道mysql_num_rows是否正在执行其工作,并返回FALSE并带有标题的警告消息。以下是我的简短直接代码
<?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://e2pressure@gmail.com')";
$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);
}
}
}
}
}
}
答案 0 :(得分:0)
来自PHP文档:
从结果集中检索行数。此命令仅对返回实际结果集的SELECT或SHOW等语句有效。要检索受INSERT,UPDATE,REPLACE或DELETE查询影响的行数,请使用mysql_affected_rows()。
此外,您应该使用PDO(或类似的东西)。