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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -