Page 1 of 1

php, apache web server, and hyperlink problem

Posted: Fri Nov 22, 2002 9:48 am
by Genteel Beaux
How does one access an outside website using an hyperlink?

Here is my code:

Code: Select all

<?php
$conn = mysql_connect("localhost","","");

$query = "SELECT * FROM student";

$resultID = mysql_db_query("test_db", $query, $conn);

for ($x = 0; $x < mysql_num_rows($resultID); $x++)
{
	$row = mysql_fetch_assoc($resultID);
	print "<table><tr>";
	print "<a href=" . $rowї'student_key'] . ">" . $rowї'student_class'] . " </a>";
	print "</tr></table>";
}
?>
When I run it, I get this:

freshman
sophmore
junior
senior
graduate
Look fine except the I wanted to try to link to a website on the internet. Instead of getting

http//www.hotmail.com


I would get

http://127.0.0.1/http//www.hotmail.com

How does one link outside of the web server?

Posted: Fri Nov 22, 2002 10:00 am
by mydimension
what is the value of $row['student_key']

Posted: Fri Nov 22, 2002 10:07 am
by cybaf
Just to check... was it just a typo when you wrote http//www.hotmail.com ??

because if then... you missed out the ":" after http... :)

otherwise... like the above reply: need to know the value of the variable $row['student_key']

//cybaf

Posted: Fri Nov 22, 2002 11:11 am
by Genteel Beaux
It is listed as http://www.hotmail.com in the database.

The value of the $row['student_key'] is http://127.0.0.1/http://www.hotmail.com.

Yes that was a typo earlier. :wink:

Posted: Fri Nov 22, 2002 11:18 am
by mydimension
it looks like the value you are putting into the databse is getting inserted incorrectly. may we see the code that inserts this value into the DB?

Posted: Fri Nov 22, 2002 2:00 pm
by Genteel Beaux
There is no insert code. I plugged that data in manually.

Posted: Fri Nov 22, 2002 5:27 pm
by mydimension
if you do
print $row['student_key'];
do you still get http://127.0.0.1/http://www.hotmail.com
if not than you are using invalid html markup and not providing a proper url to the href attrib.

Posted: Sun Nov 24, 2002 8:42 am
by Genteel Beaux
When I do

print $row['student_key'];

I get

http://www.hotmail.com

But whenever I try to do a hyperlink, my web server's IP address is always in front. I don't know how to get rid of it when I try to access internet webpages from my pages.

Posted: Sun Nov 24, 2002 9:09 am
by Genteel Beaux
Nevermind I found it on an another message board.

Instead of:

Code: Select all

<?php

print "<a href=" . $rowї'student_key'] . ">";

?>
I was suppose to use this:

Code: Select all

<?php

print "<a href="http://{$rowї'student_key']}">";

?>