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
https://forums.phpfreaks.com/topic/76896-solved-how-is-this-not-working-simple/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.