Re: php/mysql Query Question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 starter




admin@xxxxxxxxxxxxxxxxxxx wrote:
> Would you mind giving me an example of this that i can stick right into a 
blank php file and run.
> 
> I get what you are saying but i cant seem to make that even echo out the 
data.  php 5.2 mysql 5.1.3 Apache 2.2

<?php

$db   = 'db';
$host = 'host';
$user = 'user';
$pass = 'pass';

$query = "select * from my_table";

$db   = escapeShellArg( $db );
$host = escapeShellArg( $host );
$user = escapeShellArg( $user );
$pass = escapeShellArg( $pass );

$query = escapeShellArg( $query );

$command = "echo $query | mysql --html -h$host -u$user -p$pass $db";

echo 'Command: '.$command."\n";
$html = `$command`;
echo $html."\n";

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux