我现在真的很困惑..我使这个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'"); } } ?>我已经用echo $text确认了$text输出,但是当我在带有php send_sms.php终端中运行它时总是说出意外的'('
任何人都可以告诉我这里有什么不对吗??或者我不能把运行php脚本放在/ var / www / ??之外 请帮帮我..
I'm really confuse right now..i make this php script to send sms with gammu and put it in my home directory
<?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'"); } } ?>I already confirm the $text output with echo $text, but when i run it in terminal with php send_sms.php it always say unexpected '('
can anyone tell me whats wrong here??Or i cant put run php script outside /var/www/?? please help me..
最满意答案
我解决了这个问题,感谢@ 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
I solved this problem thankx to @zerkms..I just dont quote the $sending['content'] part in the earlier code...
so this is the new code:
<?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'"); } } ?>if you have same problem hope search engine find this...once again thank you zerkms
更多推荐
发布评论