Home > Archive > PHP DB > September 2005 > newbie question on PHP & Mysql...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
newbie question on PHP & Mysql...
|
|
| Evert Meulie 2005-09-21, 7:55 am |
| Hi all!
I'm taking my first steps with PHP & MySQL.
Can anyone give me a hint on why this would not work?
*********************
$result = mysql_query('SELECT SUM(AcctInputOctets), SUM(AcctOutputOctets) FROM radacct WHERE username = $argv[1] ');
echo mysql_result($result,0), "\n";
echo mysql_result($result,0,1);
*********************
I get: Warning: mysql_result(): supplied argument is not a valid MySQL result resource
Regards,
Evert
| |
| Sylvain Gourvil 2005-09-21, 7:55 am |
| Hi !
Could you do a "print_r($result)" after your mysql_query ?
Or you sure of your argv[1] ?
Sylvain Gourvil
Evert Meulie wrote:
> Hi all!
>
> I'm taking my first steps with PHP & MySQL.
>
> Can anyone give me a hint on why this would not work?
>
> *********************
>
> $result = mysql_query('SELECT SUM(AcctInputOctets),
> SUM(AcctOutputOctets) FROM radacct WHERE username = $argv[1] ');
> echo mysql_result($result,0), "\n";
> echo mysql_result($result,0,1);
>
> *********************
>
>
> I get: Warning: mysql_result(): supplied argument is not a valid MySQL
> result resource
>
>
>
> Regards,
> Evert
| |
| Sigrid Krug 2005-09-21, 7:55 am |
| Hi Evert, try:
echo mysql_result($result,0,0), "\n";
echo mysql_result($result,0,1);
You forgot a zero...
Regards, Sigrid
"Evert Meulie" <evert@witelcom.net> schrieb im Newsbeitrag
news:0tn703-4df.ln1@witelcom.com...
> Hi all!
>
> I'm taking my first steps with PHP & MySQL.
>
> Can anyone give me a hint on why this would not work?
>
> *********************
>
> $result = mysql_query('SELECT SUM(AcctInputOctets), SUM(AcctOutputOctets)
FROM radacct WHERE username = $argv[1] ');
> echo mysql_result($result,0), "\n";
> echo mysql_result($result,0,1);
>
> *********************
>
>
> I get: Warning: mysql_result(): supplied argument is not a valid MySQL
result resource
>
>
>
> Regards,
> Evert
| |
| Sigrid Krug 2005-09-21, 7:55 am |
| Hi Evert, try:
echo mysql_result($result,0,0), "\n";
echo mysql_result($result,0,1);
You forgot a zero...
Regards, Sigrid
"Evert Meulie" <evert@witelcom.net> schrieb im Newsbeitrag
news:0tn703-4df.ln1@witelcom.com...
> Hi all!
>
> I'm taking my first steps with PHP & MySQL.
>
> Can anyone give me a hint on why this would not work?
>
> *********************
>
> $result = mysql_query('SELECT SUM(AcctInputOctets), SUM(AcctOutputOctets)
FROM radacct WHERE username = $argv[1] ');
> echo mysql_result($result,0), "\n";
> echo mysql_result($result,0,1);
>
> *********************
>
>
> I get: Warning: mysql_result(): supplied argument is not a valid MySQL
result resource
>
>
>
> Regards,
> Evert
| |
| Evert Meulie 2005-09-21, 6:56 pm |
| Hi!
I've tried your suggestions, but still get the same error message. The 'print_r($result);' that I added does not print anything, so that would explain why I get the errors.
My idea is to call this script with a value, like:
script.php value
Doesn't that put the value in $argv[1] ?
Regards,
Evert
Unnawut Leepaisalsuwanna wrote:
> Hi,
>
> I guess you used a single quote over the query so the text, $argv[1],
> was entered into the query rather than the value inside it.
>
> try:
>
> $result = mysql_query('SELECT SUM(AcctInputOctets),
> SUM(AcctOutputOctets) FROM radacct WHERE username = ' .$argv[1] );
>
> OR
>
> $result = mysql_query("SELECT SUM(AcctInputOctets),
> SUM(AcctOutputOctets) FROM radacct WHERE username = $argv[1]");
>
> should do the trick
>
> 21nu
>
> Sylvain Gourvil wrote:
>
>
>
| |
| Sylvain Gourvil 2005-09-21, 6:56 pm |
| Evert Meulie wrote:
> Hi!
>
> I've tried your suggestions, but still get the same error message. The
> 'print_r($result);' that I added does not print anything, so that would
> explain why I get the errors.
>
> My idea is to call this script with a value, like:
> script.php value
>
> Doesn't that put the value in $argv[1] ?
>
>
> Regards,
> Evert
What do you use to execute your php scripts.
Php on linux ssh ?
Apache ?
call your script with script.php?var=value to get your value in $_GET['var']
But even if your args are emptied, it should return an error in your
$result !
[color=darkred]
>
>
>
> Unnawut Leepaisalsuwanna wrote:
>
| |
| Evert Meulie 2005-09-22, 3:56 am |
| Thanks! :-)
Your solution gives me exactly what I need!
Regards,
Evert
Ziv Gabel wrote:
> Try This
> $result = mysql_query("SELECT SUM(AcctInputOctets),SUM(AcctOutputOctet
s)
> FROM radacct WHERE username = '$argv[1]' ");
>
> this will make sure that even if $arg[1] is empty it still get ''
> (empty) as part of the query
>
>
> ----- Original Message ----- From: "Sylvain Gourvil"
> <opensource_france@yahoo.fr>
> To: <php-db@lists.php.net>
> Sent: Wednesday, September 21, 2005 3:26 PM
> Subject: [PHP-DB] Re: newbie question on PHP & Mysql...
>
>
>
>
>
> ****************************************
****************************************
****
>
> This footnote confirms that this email message has been scanned by
> PineApp Mail-SeCure for the presence of malicious code, vandals &
> computer viruses.
> ****************************************
****************************************
****
>
>
|
|
|
|
|