For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > December 2005 > Re: [PHP-DB] problem of retrieving urls from mysql









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] problem of retrieving urls from mysql
Edward Gray

2005-12-07, 6:56 pm

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

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
<src=3D\"$temp\">
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 <egray@umw.edu> wrote:[color=darkred]
>
> 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
>
> $url =3D str_replace("www.mydomain.com","",$url)
>
> bastien
>
>
> get
> that?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php=20
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com