Re: php/mysql Query Question.
| From: | Robert Cummings | Date: | Wed, 16 Sep 2009 14:00:14 +0000 |
| Subject: | Re: php/mysql Query Question. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298102@lists.php.net to get a copy of this message | ||
admin@buskirkgraphics.com wrote:
I tend to do this robert, while looking at your example i thought to myself since i am trying to mimick a shell command why not run one. Result: <? $db = 'db'; $host = 'host'; $user = 'user'; $pass = 'pass'; $query = "select * from $db.my_table"; $ddvery = shell_exec("mysql -u$user -p$pass --html --execute=$query"); echo "<pre>$ddvery</pre>"; ?> Not are the results safe but the unlimited possibilites are amazing. Thanks so much for the kick starterThis presumes your information is all safe and that there are no special shell characters in any of the configuration settings (now and in the future). Also, the shell_exec() function is "identical" to the backtick operator that I used in my example (see the help). You've essentially done what I did, but made it less robust... except for the use of the --execute parameter which I wasn't aware existed since it's just as easy to pipe :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP