lbcfloors Posted August 20, 2009 Share Posted August 20, 2009 I am trying to put a link to a page pulled from a MySQL query. instead of getting http://link.com I am getting http://myserver.com/http://link.com "echo $db_field['item']" is http://link.com here is my code <?PHP $user_name = "user"; $password = "pass"; $database = "counter"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SELECT * FROM counter ORDER BY viewcount DESC "; $result = mysql_query($SQL); echo "<table border='1'>"; echo "<tr>"; while ($db_field = mysql_fetch_assoc($result)) { echo "<td>Page: ".$db_field['item']."<br/>\n"; echo "<td>Count: ".$db_field['viewcount']."<br/>\n"; echo "<td><a href=".$db_field['item']."><i>View</i></a>"; echo "<tr>"; } mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); } ?> Link to comment https://forums.phpfreaks.com/topic/171186-my-servers-url-is-stuck-in-front-of-my-links-called-from-mysql/ Share on other sites More sharing options...
Eiolon Posted August 20, 2009 Share Posted August 20, 2009 How is the "item" being entered into the database. Is it entered as http://link.com or just as link.com? Link to comment https://forums.phpfreaks.com/topic/171186-my-servers-url-is-stuck-in-front-of-my-links-called-from-mysql/#findComment-902725 Share on other sites More sharing options...
lbcfloors Posted August 20, 2009 Author Share Posted August 20, 2009 I was entering link.com. I tried entering http://link.com in the db and it works! good enough for me. thanks! Link to comment https://forums.phpfreaks.com/topic/171186-my-servers-url-is-stuck-in-front-of-my-links-called-from-mysql/#findComment-902730 Share on other sites More sharing options...
Eiolon Posted August 20, 2009 Share Posted August 20, 2009 You can also make it so http:// is already so people only need to put link.com: echo "<td><a href="http://.$db_field['item']."><i>View</i></a>"; If you want to get fancy, you can also check to see if http:// is in the field or not, and if not, have if be added when outputted. Link to comment https://forums.phpfreaks.com/topic/171186-my-servers-url-is-stuck-in-front-of-my-links-called-from-mysql/#findComment-902768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.