php, apache web server, and hyperlink problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

php, apache web server, and hyperlink problem

Post 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?
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

what is the value of $row['student_key']
User avatar
cybaf
Forum Commoner
Posts: 89
Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden

Post 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
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post 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:
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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?
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post by Genteel Beaux »

There is no insert code. I plugged that data in manually.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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.
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post 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.
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post 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']}">";

?>
Post Reply