problem of retrieving urls from mysql

problem of retrieving urls from mysql

am 06.12.2005 18:51:18 von Mohamed Yusuf

------=_Part_5819_21274447.1133891478168
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I would like to store and retrieve urls, but I have problem which is I get
my url + the other url, Instead I should get another url only

$temp =3D linkurl;
echo "$temp";

the echo prints something like this
http://www.mydomain.com/www.otherlink.com

so I wan get rid off my url and get only other link, so how can I do that?

thanks in advance

------=_Part_5819_21274447.1133891478168--

RE: problem of retrieving urls from mysql

am 06.12.2005 19:44:08 von Bastien Koert

$url = str_replace("www.mydomain.com","",$url)

bastien


>From: Mohamed Yusuf
>To: php-db@lists.php.net
>Subject: [PHP-DB] problem of retrieving urls from mysql
>Date: Tue, 6 Dec 2005 09:51:18 -0800
>
>I would like to store and retrieve urls, but I have problem which is I get
>my url + the other url, Instead I should get another url only
>
>$temp = linkurl;
>echo "$temp";
>
>the echo prints something like this
>http://www.mydomain.com/www.otherlink.com
>
>so I wan get rid off my url and get only other link, so how can I do that?
>
>thanks in advance

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: problem of retrieving urls from mysql

am 07.12.2005 18:04:21 von Edward Gray

actually, you may want to check the source of the page. if the url does =
not start with "http://" (or https, or ftp, etc.), browsers will assume =
the link is on the current server. how are you storing the urls? as full =
urls, as domain/path/file.htm, ....? if all of your urls should start =
with "http://", you could either store them in the database that way or
echo 'http://' . $temp;

hope this helps.


Edward Gray
Web Development Team
University of Mary Washington
540-654-1564

>>> "Bastien Koert" 12/06/05 1:44 PM >>>
$url =3D str_replace("www.mydomain.com","",$url)

bastien


>From: Mohamed Yusuf
>To: php-db@lists.php.net=20
>Subject: [PHP-DB] problem of retrieving urls from mysql
>Date: Tue, 6 Dec 2005 09:51:18 -0800
>
>I would like to store and retrieve urls, but I have problem which is I =
get
>my url + the other url, Instead I should get another url only
>
>$temp =3D linkurl;
>echo "$temp";
>
>the echo prints something like this
>http://www.mydomain.com/www.otherlink.com=20
>
>so I wan get rid off my url and get only other link, so how can I do =
that?
>
>thanks in advance

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: problem of retrieving urls from mysql

am 07.12.2005 18:47:40 von Mohamed Yusuf

------=_Part_1333_2164028.1133977660705
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I am getting link from visitor using form, that means I don't have control
what they would type. e.g they may type
http://www.suggestedlink.com/myfav.wav, www.suggestedlink.com/myfav.ram and
http://suggestedlink.com/myfav.mp3 or so I am looking general version whic=
h
can handle all.

and on top of that I wanted to play music file in to the default player, bu=
t
it did not work. I used something like this.

select music_file from music where id=3D\"$id\"
$temp =3D $result

so everything is working fine except I got file not found, and the file pat=
h
is something like this http://www.mydomain.com/www.suggestedlink/myfav.mp3
so what should I do.


On 12/7/05, Edward Gray wrote:
>
> actually, you may want to check the source of the page. if the url does
> not start with "http://" (or https, or ftp, etc.), browsers will assume t=
he
> link is on the current server. how are you storing the urls? as full ur=
ls,
> as domain/path/file.htm, ....? if all of your urls should start with
> "http://", you could either store them in the database that way or
> echo 'http://' . $temp;
>
> hope this helps.
>
>
> Edward Gray
> Web Development Team
> University of Mary Washington
> 540-654-1564
>
> >>> "Bastien Koert" 12/06/05 1:44 PM >>>
> $url =3D str_replace("www.mydomain.com","",$url)
>
> bastien
>
>
> >From: Mohamed Yusuf
> >To: php-db@lists.php.net
> >Subject: [PHP-DB] problem of retrieving urls from mysql
> >Date: Tue, 6 Dec 2005 09:51:18 -0800
> >
> >I would like to store and retrieve urls, but I have problem which is I
> get
> >my url + the other url, Instead I should get another url only
> >
> >$temp =3D linkurl;
> >echo "$temp";
> >
> >the echo prints something like this
> >http://www.mydomain.com/www.otherlink.com
> >
> >so I wan get rid off my url and get only other link, so how can I do
> that?
> >
> >thanks in advance
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_1333_2164028.1133977660705--

Re: problem of retrieving urls from mysql

am 07.12.2005 19:04:04 von Edward Gray

you should then check the strings provided by your users. you can do this =
before or after the link is added to your database.

use a regex to verify that the url provided is a full url (starting with =
'http://', etc.). if it is not, then prepend 'http://'. i would =
recommend doing this before saving the url to the database as the url will =
be written once, but is likely to be read many times. if you decide to do =
this when pulling the url out, you will need to run the regex each time =
the url is pulled from the database.



Edward Gray
Web Development Team
University of Mary Washington
540-654-1564

>>> Mohamed Yusuf 12/07/05 12:47 PM >>>
I am getting link from visitor using form, that means I don't have control
what they would type. e.g they may type
http://www.suggestedlink.com/myfav.wav, www.suggestedlink.com/myfav.ram =
and
http://suggestedlink.com/myfav.mp3 or so I am looking general version =
which
can handle all.

and on top of that I wanted to play music file in to the default player, =
but
it did not work. I used something like this.

select music_file from music where id=3D\"$id\"
$temp =3D $result

so everything is working fine except I got file not found, and the file =
path
is something like this http://www.mydomain.com/www.suggestedlink/myfav.mp3=
=20
so what should I do.


On 12/7/05, Edward Gray wrote:
>
> actually, you may want to check the source of the page. if the url does
> not start with "http://" (or https, or ftp, etc.), browsers will assume =
the
> link is on the current server. how are you storing the urls? as full =
urls,
> as domain/path/file.htm, ....? if all of your urls should start with
> "http://", you could either store them in the database that way or
> echo 'http://' . $temp;
>
> hope this helps.
>
>
> Edward Gray
> Web Development Team
> University of Mary Washington
> 540-654-1564
>
> >>> "Bastien Koert" 12/06/05 1:44 PM >>>
> $url =3D str_replace("www.mydomain.com","",$url)
>
> bastien
>
>
> >From: Mohamed Yusuf
> >To: php-db@lists.php.net=20
> >Subject: [PHP-DB] problem of retrieving urls from mysql
> >Date: Tue, 6 Dec 2005 09:51:18 -0800
> >
> >I would like to store and retrieve urls, but I have problem which is I
> get
> >my url + the other url, Instead I should get another url only
> >
> >$temp =3D linkurl;
> >echo "$temp";
> >
> >the echo prints something like this
> >http://www.mydomain.com/www.otherlink.com=20
> >
> >so I wan get rid off my url and get only other link, so how can I do
> that?
> >
> >thanks in advance
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php=20
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php