我现在真的很困惑..我让这个php脚本发送带有gammu的短信并把它放在我的主目录中
<?php
mysql_connect("localhost","username","password") or die("failed");
mysql_select_db("database1") or die("Database Failed");
$not_send = mysql_query("SELECT * FROM outbox WHERE status=0");
while($sending = mysql_fetch_array($not_send)){
$msg_id = $sending['id'];
$text = "gammu --sendsms TEXT ".$sending['phoneNum']." -text ".$sending['content'];
$sms = shell_exec($text);
if(preg_match("/ok/im", $sms)){
mysql_query("DELETE FROM outbox WHERE id = '$msg_id'");
}
}
?>
我已使用$text
确认echo $text
输出,但当我在php send_sms.php
的终端中运行时,它总是说意外'('
谁能告诉我这里有什么问题?或者我不能把运行php脚本放在/ var / www / ??之外 请帮帮我..
答案 0 :(得分:0)
我解决了这个问题谢谢你到@ zerkms ..我只是不引用早期代码中的$sending['content']
部分......
所以这是新代码:
<?php
mysql_connect("localhost","username","password") or die("failed");
mysql_select_db("database1") or die("Database Failed");
$not_send = mysql_query("SELECT * FROM outbox WHERE status=0");
while($sending = mysql_fetch_array($not_send)){
$msg_id = $sending['id'];
$text = "gammu --sendsms TEXT ".$sending['phoneNum']." -text '".$sending['content'."'"];
$sms = shell_exec($text);
if(preg_match("/ok/im", $sms)){
mysql_query("DELETE FROM outbox WHERE id = '$msg_id'");
}
}
?>
如果你有同样的问题希望搜索引擎找到这个...再次感谢zerkms