Jump to content

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

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.