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:

  1. 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 path mysql binary. type which mysql normal user prompt find out full path executable.

  2. the command mysql may restricted system configuration not users can execute it.

  3. your php configuration on web server prohibits use of system().

  4. you can same information running (assuming have mysql configured php installation):

    $con = new mysqli("localhost", "root", "mypassword"); printf("%s", $con->server_info); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -