Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-01-2010, 02:50 AM   PM User | #1
countrygirl
New Coder

 
Join Date: Apr 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
countrygirl is an unknown quantity at this point
Simple SQL Query D'OH

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
countrygirl is offline   Reply With Quote
Old 04-01-2010, 02:54 AM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Code:
$result = mysql_query("SELECT name FROM si_customers WHERE id='$_SESSION[user_id]'");
$customer_name = mysql_result($result);
MattF is offline   Reply With Quote
Old 04-01-2010, 03:20 AM   PM User | #3
countrygirl
New Coder

 
Join Date: Apr 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
countrygirl is an unknown quantity at this point
Hmm, I got an error with that:

Warning: Wrong parameter count for mysql_result()
countrygirl is offline   Reply With Quote
Old 04-01-2010, 03:25 AM   PM User | #4
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Code:
$customer_name = mysql_result($result, 0);
MattF is offline   Reply With Quote
Users who have thanked MattF for this post:
countrygirl (04-01-2010)
Old 04-01-2010, 03:31 AM   PM User | #5
countrygirl
New Coder

 
Join Date: Apr 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
countrygirl is an unknown quantity at this point
Thank you Matt, that was the ticket
countrygirl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:45 AM.


Advertisement
Log in to turn off these ads.