alconebay Posted April 1, 2008 Share Posted April 1, 2008 I have a website field in mysql that I want to echo in a table with php. What happens is my domain automatically gets put in front of the website address being pulled from mysql. Example: <a href="<? echo $web; ?>">Website</a> if "$web" was "www.someothersite.com" the link that displays on the page will be http://www.mywebsite.com/www.someothersite.com How do I get my domain out of the link? Quote Link to comment https://forums.phpfreaks.com/topic/99020-solved-data-in-mysql-echoed-in-php-as-a-link/ Share on other sites More sharing options...
papaface Posted April 1, 2008 Share Posted April 1, 2008 You'd have to correct what ever is causing the problem as it looks like your appending your address to any href attribute. Therefore there is no way to correct it without going to the source - to my knowledge. Quote Link to comment https://forums.phpfreaks.com/topic/99020-solved-data-in-mysql-echoed-in-php-as-a-link/#findComment-506679 Share on other sites More sharing options...
alconebay Posted April 1, 2008 Author Share Posted April 1, 2008 Thanks, I found out that you have to put a "http://" in front of any web site addresses in the database. That fixed my problem. Quote Link to comment https://forums.phpfreaks.com/topic/99020-solved-data-in-mysql-echoed-in-php-as-a-link/#findComment-506738 Share on other sites More sharing options...
redarrow Posted April 1, 2008 Share Posted April 1, 2008 no you dont have to do ya what about this then will it work. <?php //database connection. $sql="select * from links"; $result=mysql_query($sql) or die(mysql_error()); while($x=mysql_fetch_assoc($result)){ echo" http://".$x['links']." "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/99020-solved-data-in-mysql-echoed-in-php-as-a-link/#findComment-506744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.