Jump to content

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>";
}
?>

You're trying to issue an opening <?php tag when you're already in <?php. Look at the html source of the page, and you should see the <?php tag and 'echo' in the href= attribute.

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>
<?
}
?>

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.