|
|
|
|
![]() ![]() |
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']; |
|
|
|
Nov 6 2007, 08:27 PM
Post
#2
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 1,912 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
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'];
|
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 12th May 2008 - 11:05 AM |