By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

script to generate an external link

P: n/a
hello all, if anyone out there could help me i would really appreciate
it. i am very much a novice coder. I have a site we are building and
we have created a section in the admin area to allow the client to add
external links to their web site. the problem we keep running into is
the links that get generated have the home page url in front.

ie. lets say the web site address is http://abc.com and i create an
external link called xyz. the url i put in the link generator is www.xyz.com
but what happens is the script spits out a link with this url:
http://abc.com/xyz.com.

below is the script:

//include external links
$query = "SELECT LINK_HREF, LINK_NAME
FROM LINK";

$lresult = mysql_query($query);

if (mysql_num_rows($lresult) == 0)
{
echo 'Verses being update.';
}
else
{
while ($row = mysql_fetch_array($lresult, MYSQL_ASSOC))
{
print "{$trOpen}" . "<a href=\"{$row['LINK_HREF']}\">" .
"{$row['LINK_NAME']}" . "</a>" . "{$trClose}";
}
}

If anyone could help i would be very grateful

God bless
jason

May 28 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
you could have the users put the http:// inside their links, or manually
adding it in the code before you place the link value inside the href
attribute of the link tag.
<in**@musiclanerecording.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
hello all, if anyone out there could help me i would really appreciate
it. i am very much a novice coder. I have a site we are building and
we have created a section in the admin area to allow the client to add
external links to their web site. the problem we keep running into is
the links that get generated have the home page url in front.

ie. lets say the web site address is http://abc.com and i create an
external link called xyz. the url i put in the link generator is
www.xyz.com
but what happens is the script spits out a link with this url:
http://abc.com/xyz.com.

below is the script:

//include external links
$query = "SELECT LINK_HREF, LINK_NAME
FROM LINK";

$lresult = mysql_query($query);

if (mysql_num_rows($lresult) == 0)
{
echo 'Verses being update.';
}
else
{
while ($row = mysql_fetch_array($lresult, MYSQL_ASSOC))
{
print "{$trOpen}" . "<a href=\"{$row['LINK_HREF']}\">" .
"{$row['LINK_NAME']}" . "</a>" . "{$trClose}";
}
}

If anyone could help i would be very grateful

God bless
jason

May 28 '07 #2

P: n/a
On May 28, 3:16 pm, "Steve Belanger" <desk...@ebinformatique.com>
wrote:
you could have the users put the http:// inside their links, or manually
adding it in the code before you place the link value inside the href
attribute of the link tag.

<i...@musiclanerecording.comwrote in message

news:11**********************@k79g2000hse.googlegr oups.com...
hello all, if anyone out there could help me i would really appreciate
it. i am very much a novice coder. I have a site we are building and
we have created a section in the admin area to allow the client to add
external links to their web site. the problem we keep running into is
the links that get generated have the home page url in front.
ie. lets say the web site address ishttp://abc.comand i create an
external link called xyz. the url i put in the link generator is
www.xyz.com
but what happens is the script spits out a link with this url:
http://abc.com/xyz.com.
below is the script:
//include external links
$query = "SELECT LINK_HREF, LINK_NAME
FROM LINK";
$lresult = mysql_query($query);
if (mysql_num_rows($lresult) == 0)
{
echo 'Verses being update.';
}
else
{
while ($row = mysql_fetch_array($lresult, MYSQL_ASSOC))
{
print "{$trOpen}" . "<a href=\"{$row['LINK_HREF']}\">" .
"{$row['LINK_NAME']}" . "</a>" . "{$trClose}";
}
}
If anyone could help i would be very grateful
God bless
jason
Not sure i follow

May 28 '07 #3

P: n/a
On Mon, 28 May 2007 20:16:42 GMT, "Steve Belanger"
<de*****@ebinformatique.comwrote:
>you could have the users put the http:// inside their links, or manually
adding it in the code before you place the link value inside the href
attribute of the link tag.
<in**@musiclanerecording.comwrote in message
news:11**********************@k79g2000hse.googleg roups.com...
>hello all, if anyone out there could help me i would really appreciate
it. i am very much a novice coder. I have a site we are building and
we have created a section in the admin area to allow the client to add
external links to their web site. the problem we keep running into is
the links that get generated have the home page url in front.

ie. lets say the web site address is http://abc.com and i create an
external link called xyz. the url i put in the link generator is
www.xyz.com
but what happens is the script spits out a link with this url:
http://abc.com/xyz.com.

below is the script:

//include external links
$query = "SELECT LINK_HREF, LINK_NAME
FROM LINK";

$lresult = mysql_query($query);

if (mysql_num_rows($lresult) == 0)
{
echo 'Verses being update.';
}
else
{
while ($row = mysql_fetch_array($lresult, MYSQL_ASSOC))
{
print "{$trOpen}" . "<a href=\"{$row['LINK_HREF']}\">" .
"{$row['LINK_NAME']}" . "</a>" . "{$trClose}";
}
}

If anyone could help i would be very grateful

God bless
jason
Not everyone will input a url in the format to suit you, so better
write a line to *remove* the "http://" from the input so that your
adding http:// to the output will not double up.
May 28 '07 #4

P: n/a
On May 28, 3:47 pm, jobo...@hotmail.com wrote:
On Mon, 28 May 2007 20:16:42 GMT, "Steve Belanger"

<desk...@ebinformatique.comwrote:
you could have the users put the http:// inside their links, or manually
adding it in the code before you place the link value inside the href
attribute of the link tag.
<i...@musiclanerecording.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
hello all, if anyone out there could help me i would really appreciate
it. i am very much a novice coder. I have a site we are building and
we have created a section in the admin area to allow the client to add
external links to their web site. the problem we keep running into is
the links that get generated have the home page url in front.
ie. lets say the web site address ishttp://abc.comand i create an
external link called xyz. the url i put in the link generator is
www.xyz.com
but what happens is the script spits out a link with this url:
http://abc.com/xyz.com.
below is the script:
//include external links
$query = "SELECT LINK_HREF, LINK_NAME
FROM LINK";
$lresult = mysql_query($query);
if (mysql_num_rows($lresult) == 0)
{
echo 'Verses being update.';
}
else
{
while ($row = mysql_fetch_array($lresult, MYSQL_ASSOC))
{
print "{$trOpen}" . "<a href=\"{$row['LINK_HREF']}\">" .
"{$row['LINK_NAME']}" . "</a>" . "{$trClose}";
}
}
If anyone could help i would be very grateful
God bless
jason

Not everyone will input a url in the format to suit you, so better
write a line to *remove* the "http://" from the input so that your
adding http:// to the output will not double up.
Well, i just added the http:// to the address and everything worked,
so i think what i will do is hardcode in the http:// so the client
only has to put www.xxx.xxx

May 28 '07 #5

P: n/a
Well, i just added the http:// to the address and everything worked,
so i think what i will do is hardcode in the http:// so the client
only has to putwww.xxx.xxx
Thats all fine to take the easy way, but clients WILL enter
http://www.example.com.

Unless you have a select box/checkbox/radio buttons etc where you
write the values out, expect users to enter invalid data

If you expect data in a specific format, you need to validate it (or
as the previous poster explained, strip the http:// if it exists)

May 28 '07 #6

P: n/a
On May 28, 5:13 pm, dave <dave.wa...@gmail.comwrote:
Well, i just added the http:// to the address and everything worked,
so i think what i will do is hardcode in the http:// so the client
only has to putwww.xxx.xxx

Thats all fine to take the easy way, but clients WILL enterhttp://www.example.com.

Unless you have a select box/checkbox/radio buttons etc where you
write the values out, expect users to enter invalid data

If you expect data in a specific format, you need to validate it (or
as the previous poster explained, strip the http:// if it exists)
I really appreciate all the help, thank you all very much

God bless
jason

May 29 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.