我有这个脚本,用于从一个表中选择描述并将其插入另一个表。
<?php
/**
Report Errors
*/
error_reporting(E_ALL);
$mysqli = new mysqli("localhost", "root", "", "test");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query("select subscriber_number,subscriber_category from subscriber_choices");
/*
500 Records Here
*/
$i = 0;
while($row = $result->fetch_array())
{
$subscriber_number = $row['subscriber_number'];
$subscriber_category = $row['subscriber_category'];
$mysqli->query("select description from jobs_content where category = $subscriber_category order by rand() limit 1 ");
$text_message = $mysqli->query("select description from jobs_content where category = '$subscriber_category' order by rand() limit 1")->fetch_object()->description;
$mysqli->query("insert into le_grand_out dest_msisdn,text_message,sender_name,service_id values ($subscriber_number,'$text_message',6789900,6388398399004)");
}
$result->close()
?>
当我运行此脚本时,我在此行上收到错误
$text_message = $mysqli->query("select description from jobs_content where category = '$subscriber_category' order by rand() limit 1")->fetch_object()->description;
当我例如写
时有效$text_message = $mysqli->query("select description from jobs_content where category = 'general' order by rand() limit 1")->fetch_object()->description;
为什么我收到此错误
Notice: Trying to get property of non-object in /var/www/html/send_sms.php on line 26
答案 0 :(得分:1)
答案 1 :(得分:0)
似乎你查询没有返回任何尝试正确检查或使用的查询 if($ result) { //在这里获取结果 }