Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Retrieve 1
deepod
post Nov 6 2007, 03:52 PM
Post #1


Newbie [Level 1]
*

Group: Members
Posts: 21
Joined: 3-November 07
Member No.: 52,408



Hi,

I am tring to get one single cell from a database. The primary key is username. I want to store the single cell in a variable called $charity. The code below seems to work. However, this outputs to the screen the answer. I want to store the answer in a variable.
CODE
$query="SELECT charity FROM `users` WHERE username='$username'";
$result=mysql_query($query);
$row = mysql_fetch_assoc($result);
echo $row['charity'];

biggrin.gif

Notice from rvalkass:

Code needs to go into CODE tags. List of BBCodes.
Go to the top of the page
 
+Quote Post
rvalkass
post Nov 6 2007, 08:27 PM
Post #2


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 1,914
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



The reason is the last line: you echo out the result! Echo is used to output something to the browser, and is often used to output raw HTML code. If you want to store it as a variable, use the following code, in place of your current last line:

CODE
$charity = $row['charity'];
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Reset, Retrieve Windows Xp User Password ?(21)
  2. How To Retrieve My Cpanel Password?(10)


 



- Lo-Fi Version Time is now: 13th May 2008 - 03:06 PM