Re: Re: newbie question on PHP & Mysql...
| From: | Unnawut Leepaisalsuwanna | Date: | Wed, 21 Sep 2005 11:52:31 +0000 |
| Subject: | Re: Re: newbie question on PHP & Mysql... | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40326@lists.php.net to get a copy of this message | ||
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:
> 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
>
>