Jump to content

[SOLVED] how is this not working???!!! simple


mybluehair

Recommended Posts

take a look at this:

<?

$database = "*******";

$username = "**********";

$password = "**********";

 

$one = "one and all";

 

mysql_connect(localhost,$username,$password);

@mysql_select_db($database) or die ( "unable to connect");

$query="SELECT * FROM settings";

$result=mysql_query($query);

 

mysql_close();

 

$name=mysql_result($result, "password", "chatname");

 

 

echo 'welcome $one to here';

 

dont pay attention to all the mysql crap, but pay attention to the echo code. $one = "one and all" as you can see up on the top, but when i veiw this page here is EXACTLY what i see:

 

welcome $one to here

 

what did i do wrong?

 

Link to comment
Share on other sites

There are plenty of ways of achieving what you need :

 

1) Using double quotes (") - echo "welcome ".$one." to here";

2) Using double quotes (") - echo "welcome {$one} to here";

3) Using double quotes (") - echo "welcome $one to here";

4) Using single quotes (') - echo 'welcome '.$one.' to here';

5) Using sprintf replacement - echo sprintf("welcome %s to here",$one);

6) Using printf replacement - printf("welcome %s to here",$one);

7) Using print - print "welcome $one to here";

 

Hope those help identify your options.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.