错误在ubuntu服务器终端中运行php脚本(error run php script in ubuntu server terminal)

编程入门 行业动态 更新时间:2024-10-25 00:34:10
错误在ubuntu服务器终端中运行php脚本(error run php script in ubuntu server terminal)

我现在真的很困惑..我使这个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

更多推荐

本文发布于:2023-07-30 00:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1320844.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   脚本   错误   服务器   server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!