Jump to content

[SOLVED] Echo Link?


Lambneck

Recommended Posts

you are using a literal string, you have two options:

 

concatenate

		echo '<a href="www.mysite.com/display.php">'.$row['col_4'].'</a>';

 

or inline

		echo "<a href='www.mysite.com/display.php'>'$row['col_4']'</a>";

 

make sure any quotes are escaped, eg:

 

		echo "<a href=\"www.mysite.com/display.php\">'$row['col_4']'</a>";

 

hope thsi helps,

Link to comment
https://forums.phpfreaks.com/topic/100420-solved-echo-link/#findComment-513559
Share on other sites

hmm, it still didn't work.

this is the code as it is now:

 

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

$result = mysql_query("SELECT col_4 FROM {$table}");
if (!$result) {
    die("Query to show fields from table failed:".mysql_error());
}

while($row = mysql_fetch_array($result))
{
	echo "<a href=\"www.mysite.com/display.php\">'$row['col_4']'</a>";
	echo "<br />";
}
mysql_free_result($result);

Link to comment
https://forums.phpfreaks.com/topic/100420-solved-echo-link/#findComment-513572
Share on other sites

Lambneck, what you have to watch for in php is the way you use double and single quotes together. Double quotes will override everything where singles can be used within double. So I always try to use doubles on everything so if the need arises for singles I can easily add them in without thinking of escaping things. I don't know if this is proper or not but it is the style I have gotten used to.

 

Link to comment
https://forums.phpfreaks.com/topic/100420-solved-echo-link/#findComment-513791
Share on other sites

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.