|
|
|
|
![]() ![]() |
Jun 17 2007, 02:58 AM
Post
#1
|
|
|
Sparkx Group: [HOSTED] Posts: 355 Joined: 11-October 06 From: Dana Point, CA, USA Member No.: 16,496 |
Well I have been recieving some real good help here at astahost so I decited I just won't even try Yahoo Answers first. OK this is halfway between php and mysql. I want to echo text from MySQL that includes vars. Here is an example:
MySQL Entry CODE This is some sql entry. $var I tryied: CODE $var=("It worked"); $row = mysql_fetch_array(mysql_query("SELECT * FROM example WHERE id='5'")); $output=$row['content']; echo($output);//Doesnt work echo<<<END $output END;//Still doesnt work My wanted outcome: CODE This is some sql entry. It worked Do you understand what I am saying? Im sorry but I think I stated the question well. Thank you all very much for all the help, Sparkx |
|
|
|
Jun 17 2007, 09:46 AM
Post
#2
|
|
|
Nenad Bozidarevic Group: [MODERATOR] Posts: 1,013 Joined: 7-November 05 From: Belgrade, Serbia Member No.: 9,500 |
With just some minor modifications, it should work. Here's how I would do it.
CODE $var = 'It worked'; $row = mysql_fetch_array(mysql_query('SELECT * FROM example WHERE id=5')); $output = $row['content'] . $var; echo $output; 1. No parenthesis 2. If the ID field is numerical, there is no need for quotes 3. Besides the data extracted from the database, we need to output the variable, too 4. Again, no parenthesis I've also used single quotes instead of double quotes - both are possible, but it's just a habit |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 14th October 2008 - 01:37 AM |