Jump to content

my servers URL is stuck in front of my links called from MySQL


lbcfloors

Recommended Posts

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);

}

 

?>

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.

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.