mysql - PHP outputs from command line but not from the browser -
i have php file testphp.php
following content:
<?php echo system('mysql -u root -pmypassword -e "select version();"'); ?>
it outputs command line:
d:\>php testphp.php version() 5.5.24-log 5.5.24-log d:\>
when execute same file via web browser (http://localhost/testphp.php
) , see no output. why?
there lots of reasons this:
you using command
mysql
may not in path of user web server runs as. when run command line, running own user account. web server runs under different (restricted) account. should provide full pathmysql
binary. typewhich mysql
normal user prompt find out full path executable.the command
mysql
may restricted system configuration not users can execute it.your php configuration on web server prohibits use of
system()
.you can same information running (assuming have mysql configured php installation):
$con = new mysqli("localhost", "root", "mypassword"); printf("%s", $con->server_info);
Comments
Post a Comment