Page 1 of 1

NEED HELP - echo MySQL query result...

Posted: Thu Jun 12, 2003 7:06 pm
by BrunoAun
Hello Fellas...

This should be an easy one to you....

I am having a hard time to echo the result from a query in MySQL.
the result should be a single row from only one column:

the variable client_id is passed via form action

$client_name = mysql_query("select name from clients where client_id='$client_id' ");
$cli_name_array = array($client_name);
echo "<b>".$client_name_array[0]."</b>";

the echo command returns "RESOURCE #4" for example

Can someone help writting the right statement so it returns the actual value??

thanks in advance... 8O

Re: NEED HELP - echo MySQL query result...

Posted: Thu Jun 12, 2003 7:31 pm
by Paddy
BrunoAun wrote: $client_name = mysql_query("select name from clients where client_id='$client_id' ");
$client_name = mysql_query("select name from clients where client_id='".$client_id."' ");

You need to concatenate your strings properly. You did this on the third line of your code.

Posted: Thu Jun 12, 2003 8:50 pm
by Sevengraff

Code: Select all

$cli_name_array = array($client_name);
use mysql_fetch_array() insead of of just array().

Code: Select all

$cli_name_array = mysql_fetch_array($client_name); 
echo $cli_name_array['name'];

Posted: Thu Jun 12, 2003 9:07 pm
by BrunoAun
thanks!