Jump to content

Trying To Make A Link From My Database


vet911

Recommended Posts

I'm trying to get a webpage link from my database, if there is null it just continues, but if there it's not null I want it to place the link Visit Website.

I works if there isn't anything in the $webpage, but if there is something there it stops with this error message:

Not Found

 

The requested URL /< was not found on this server.

 

Any help would be appreciated.

 

 

 

<?php
if ($webpage==null) { echo "";}
else {
echo "<div><a href='<?php echo $webpage; ?>'>Visit Website!</a></div>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/270611-trying-to-make-a-link-from-my-database/
Share on other sites

Most likely $webpage carries an invalid link that cannot be used. Hard to tell without seeing all of the relevant code. Also it doesn't seem like there is a point to displaying an empty string, shorten the condition to:

 

<?php
if ($webpage != null)
{
 echo "<div><a href='<?php echo $webpage; ?>'>Visit Website!</a></div>";
}
?>

I want to thank you all for the help in one way or the other you all made me think about what I was doing and I came up with this solution by using some of the comments provided.

Thanks to all who posted. This is what works below.

 

<?php
if ($webpage != null)
{?>
<div><a href= "<?php echo $webpage; ?>" >Visit Website!</a></div>
<?
}
?>

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.