Jump to content
xisto Community
Sign in to follow this  
sparkx

Adding Vars To A Sql

Recommended Posts

Well I have been recieving some real good help here at Xisto 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

This is some sql entry. $var
I tryied:
$var=("It worked");$row = mysql_fetch_array(mysql_query("SELECT * FROM example WHERE id='5'")); $output=$row['content'];echo($output);//Doesnt workecho<<<END$outputEND;//Still doesnt work
My wanted outcome:
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

Share this post


Link to post
Share on other sites

With just some minor modifications, it should work. Here's how I would do it.

$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 <_<

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.