I want to exec php file test1.php
in file test.php
. My problem is when I manualy run script test.php
in terminal on the server(php /home/users/xh/*****/WWW/BP/test.php
) it will do the job and exec the test1.php
. But when I open test.php
in the browser, it will not exec the test1.php
. I added the +x permissions to the folder and to the .php files but it do not work anyway- ls -ld : drwxr-xr-x
,ls -l: -rwxr-xr-x
(on both test1 and test)
Here is test.php
:
<?php
echo "including test1\n";
exec('php -f /home/users/xh/*****/WWW/BP/test1.php');
echo "end";
test1.php
:
<?php
$db = mysql_connect('localhost:/var/run/mysql/mysql.sock', '*******', '*******');
if (!$db) die('cannot connect'.mysql_error());
if (!mysql_select_db('******', $db)) die('db not available '.mysql_error());
$var=mysql_set_charset("UTF8", $db);
if (!($result = mysql_query("INSERT INTO table VALUES ('abcdefg','100','20','3','3')", $db))) {
echo "insert not successful";
}
else
echo "insert successful";
EDIT: when in run script test1.php
by shell_exec()
it whill show this warning:
Warning: shell_exec() [function.shell-exec]: Cannot execute using backquotes in Safe Mode