Astahost.com   Mar 20, 2010
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > SQL (Structured Query Language)

Adding Vars To A Sql

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > SQL (Structured Query Language)

Adding Vars To A Sql

sparkx
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

 

 

 


Comment/Reply (w/o sign-up)

pyost
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 smile.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Adding Vars Sql


    Looking for adding, vars, sql



See Also,

*SIMILAR VIDEOS*
Searching Video's for adding, vars, sql
advertisement




Adding Vars To A Sql

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com



Creative Commons License