NEED HELP - echo MySQL query result...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BrunoAun
Forum Newbie
Posts: 4
Joined: Sat May 03, 2003 6:33 pm

NEED HELP - echo MySQL query result...

Post 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
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

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

Post 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.
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post 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'];
BrunoAun
Forum Newbie
Posts: 4
Joined: Sat May 03, 2003 6:33 pm

Post by BrunoAun »

thanks!
Post Reply