I am trying to import a database using system() in php.
It works fine when my sql file is correct.
lets say i have an error in the sql file(for eg. syntax error).
I want that exact error in a variable so I can maintain a log and alert purpose.
<?php $lastline = system("mysql -u root mydbname < /home/mydbname.sql ",$retval); echo "\nretval:"; print_r($retval); echo "\nlastline:"; print_r($lastline); ?>
Unfortunately I don’t get any errors in return when my sql is improper
When I run the above code I get to see the errors on terminal but it does not save the errors in the variables.