473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

script to generate an external link

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
6 3329
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
3
by: MeAgain | last post by:
Hi I have an external website link on my webpage which open like all the link in TARGET frame. since last week the external link vendor put script in his page which refresh and remove my frame....
12
by: Charles Law | last post by:
This is a bit of a vague question, but I am just starting on this, and wonder if anyone has ideas of where to start. I have a program that controls some external equipment. It sends messages in...
4
by: Jake j | last post by:
To those of you who sent me working examples of js include routines, much thanks. I see from them examples that what I'm trying to get to requires a higher level of js knowledge than I've got. ...
2
by: P2P | last post by:
Hi I am wondering if someone can help me here with the "perfect" marquee vertical scrolling script I've found. This marquee is great for me as it will call an external html page. This allow...
3
by: Conrad | last post by:
Hi, it seems that I have the following issue when trying to create a symbolic link within a script: FROM COMMAND LINE: The owner is set to myself. Thus, it works. FROM WEB PAGE: It doesn't...
8
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
1
by: pseudomagazine | last post by:
Little problem: Using the document.write() function and an enormous string, I have managed to create self-generated pages with functions calling code located in external scripts. The code that...
1
by: Pontifex | last post by:
Hi all, Has anyone devised a simple method for passing a string to an external script? For instance, suppose I want to produce a title bar that is very fancy and I don't want my main HTML...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.