PHP shell_exce执行命令时返回 null


php shell_exce return null when executing command

  $shell_query = "mysql -u username -p password --execute=' INSERT INTO `mawinkcms`.`tbl_current_push` (`id`, `magazine_id`, `push_keya`) VALUES(NULL, '175', 'checker');'";
  $test = shell_exec($shell_query);
  var_dump($test);

但我只得到空值作为输出。如果有人能告诉我问题是什么

你的语法似乎是错误的。试试这个:

mysql -u [username] -p -e "Enter your query here"

有关详细信息,请参阅参考

-p和密码之间不允许有空格。 或使用 --密码

-p$password

--password $password

要捕获错误消息,请使用popen()

$handle = popen('/path/to/executable 2>&1', 'r');

http://us1.php.net/popen