Re: [PHP-DB] problem of retrieving urls from mysql
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 <[EMAIL PROTECTED]> 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=\"$id\" $temp = $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 so what should I do. On 12/7/05, Edward Gray <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> 12/06/05 1:44 PM >>> > $url = str_replace("www.mydomain.com","",$url) > > bastien > > > >From: Mohamed Yusuf <[EMAIL PROTECTED]> > >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 > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] problem of retrieving urls from mysql
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=\"$id\" $temp = $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 so what should I do. On 12/7/05, Edward Gray <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> 12/06/05 1:44 PM >>> > $url = str_replace("www.mydomain.com","",$url) > > bastien > > > >From: Mohamed Yusuf <[EMAIL PROTECTED]> > >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: [PHP-DB] problem of retrieving urls from mysql
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" <[EMAIL PROTECTED]> 12/06/05 1:44 PM >>> $url = str_replace("www.mydomain.com","",$url) bastien >From: Mohamed Yusuf <[EMAIL PROTECTED]> >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: [PHP-DB] problem of retrieving urls from mysql
$url = str_replace("www.mydomain.com","",$url) bastien From: Mohamed Yusuf <[EMAIL PROTECTED]> 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