...

View Full Version : Simple SQL Query D'OH



countrygirl
04-01-2010, 02:50 AM
I feel like such a dumb a** but I can't figure out how to pull one value from a database and I have searched and searched and can't find it because it is too simple and everyone knows how to do it so why put it on the internet lol. I know it is is something stupid and I just am not seeing it but here is my code:

$result = mysql_query("SELECT name FROM si_customers WHERE id='$_SESSION[user_id]'");
$customer_name = mysql_query($result);

I have verified that my sql statement works in phpmyadmin
I have verified that there is an actual value in $_SESSION[user_id]
I have verified the table name and the column names name and id
so I gotta be doing something dumb

Please help

MattF
04-01-2010, 02:54 AM
$result = mysql_query("SELECT name FROM si_customers WHERE id='$_SESSION[user_id]'");
$customer_name = mysql_result($result);

countrygirl
04-01-2010, 03:20 AM
Hmm, I got an error with that:

Warning: Wrong parameter count for mysql_result()

MattF
04-01-2010, 03:25 AM
$customer_name = mysql_result($result, 0);

countrygirl
04-01-2010, 03:31 AM
Thank you Matt, that was the ticket



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum