RE: [PHP] Adding HTTP URL Code
Hi all! Unfortunately, I didn't receive any replies to the problem I sent out on January 16th so I thought I'd send another email and perhaps clarify what I am seeing so that maybe someone CAN help and ask if folks on the list have just not seen this issue before. The program I am working on allows the customer to view test results based on a keyword. If the results contain a URL (these URLs are entered into the MySQL database as straight text), I make it live using the code snippet below. Unfortunately, I have not been successful doing this no matter what I try. Currently, after I have run the code below, what I see is a link containing the correct text but, when you put the cursor over the link, the actual URL is that of the base browser page. For example, I am working on a file located at: http://fake.url.com/testing/Test_Results/search_keyword.php (which is called from form Search_Keyword.php). If the test results that fit the keyword search contains, say, URL http://www.cleanrun.com (again, entered into the database as plain text), this is what will show up in the search output. HOWEVER, when the cursor is placed over the URL (or the URL is clicked), the URL that appears at the bottom of the browser corresponding to the cursor'd URL is http://fake.url.com/testing/Test_Results. Is there something in my PHP config file I might be missing? Is there something in my code I'm not doing correctly? Has anyone else ever seen this problem? HELP!!! I'm at my wits end with this one. I'm afraid I'm not going to be able to make these links live which will make the tool much less usable. Please let me know if you need more information from me in order to help! Thanks so much, Katherine -Original Message- From: ELLIOTT,KATHERINE A (HP-FtCollins,ex1) [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 16, 2003 10:54 AM To: '[EMAIL PROTECTED]' Subject: RE: [PHP] Adding HTTP URL Code Thanks for all your help with my URL code problem! I have come up with a solution that seems to half work and I can't figure out what I need to do to get it fully functional. Given my data string (text) from my database, this is what I do to replace the URL text with a functioning link. I am asking folks that, if they include a URL in their results to surround it by [] so that I can search for the brackets. This is what my text replace line looks like: $data_str = eregi_replace ((\[http://)([^]]*), a href \http=\\0\\\0/a, $data_str); So, if the URL is (for example) [http://www.cleanrun.com] (in plain text), it will show up for viewing in my browser as http://www.cleanrun.com but the URL associated with it will be that of the directory in the browser Location (i.e. http://wrong.url.com/Test_Results). I've tried all sorts of things with the call to eregi_replace but can't figure out what is going on. What the hec??? Can someone help? Many thanks!! Katherine Elliott -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 2:05 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Adding HTTP URL Code On Thursday 09 January 2003 04:07, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. With regards to your original query, the answer is in the archives. Try searching for something like regex url or regex hyperlink etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* NOTICE: alloc: /dev/null: filesystem full */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adding HTTP URL Code
Thanks for all your help with my URL code problem! I have come up with a solution that seems to half work and I can't figure out what I need to do to get it fully functional. Given my data string (text) from my database, this is what I do to replace the URL text with a functioning link. I am asking folks that, if they include a URL in their results to surround it by [] so that I can search for the brackets. This is what my text replace line looks like: $data_str = eregi_replace ((\[http://)([^]]*), a href \http=\\0\\\0/a, $data_str); So, if the URL is (for example) [http://www.cleanrun.com] (in plain text), it will show up for viewing in my browser as http://www.cleanrun.com but the URL associated with it will be that of the directory in the browser Location (i.e. http://wrong.url.com/Test_Results). I've tried all sorts of things with the call to eregi_replace but can't figure out what is going on. What the hec??? Can someone help? Many thanks!! Katherine Elliott -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 2:05 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Adding HTTP URL Code On Thursday 09 January 2003 04:07, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. With regards to your original query, the answer is in the archives. Try searching for something like regex url or regex hyperlink etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* NOTICE: alloc: /dev/null: filesystem full */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding HTTP URL Code
ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. if you want to get a reply 1) look in the manual/ archives first 2) use a helpful subject line eg making links clickable 3) show us the code you have tried to get it working - and this code will help greatly in explaining what you are trying to do 4) show us the error message OR show us the output and explain what is wrong with it remember - you aren't paying for this - there are hundreds of messages a day - personally I only skim read most of them - and if a question makes little sense I'm not going to spend time on it. that said ?php $text = This is a test. It is only a test. What happens when I include a URL in my results text? http://not.a.real.url/programs This is only a test; $clickable_text = preg_replace(#(http://[^\s]+)#i, a href=\$1\$1/a, $text); echo $clickable_text; ? I haven't been particularly strict with the allowed url charecters - I've just allowed everything and assumed that the url ends with whitespace (or end of file) Sean If I have a bunch of plain text data, how can I pull out the strings containing http. I've tried several different things but what I end up with is more or less than what I want. Once I have this, I can add the URL code and replace the string but I haven't figured out how to do this. For example, what would I do if my text looks like this (not including the astrices): ** This is a test. It is only a test. What happens when I include a URL in my results text? http://not.a.real.url/programs This is only a test ** Anyone? Anyone? Thanks, Katherine -Original Message- From: ELLIOTT,KATHERINE A (HP-FtCollins,ex1) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 2:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Adding HTTP URL Code Hello, I have a string of data that can be anywhere from one line (a single URL) to many, many lines. The data is in plain text but, as I alluded, may contain one or more URLs (or none). I then take this data and put it on a web page so I would like to make any URLs in the data live. Has anyone on the list done this? If so, can you tell me how? I'm stumped. Thanks, Katherine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adding HTTP URL Code
I found this in the archives of this list message title: php parsing problem with chat message number: 103717 by: Deadsam // // URL PARSER FOR MESSAGE $msg = ereg_replace ([[:alpha:]]+://[^[:space:]]+[[:alnum:]], font color=\#00\ua href=\\\0\target=\_blank\\\0/a/u/font, $msg); //$msg = ereg_replace(\[url\]([^\[]+)\[/url\], font color=\#00\ua href=\\\1\target=\_blank\\\1/a/u/font, $msg); Might load the file in, do line by line search for this pattern if it passes then save it or do what you want. PSEUDO CODE Get File; Foreach file_line { if contains URL { do action; } } Close File; Robert Fisher Axis Solutions, Inc. __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adding HTTP URL Code
OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. If I have a bunch of plain text data, how can I pull out the strings containing http. I've tried several different things but what I end up with is more or less than what I want. Once I have this, I can add the URL code and replace the string but I haven't figured out how to do this. For example, what would I do if my text looks like this (not including the astrices): ** This is a test. It is only a test. What happens when I include a URL in my results text? http://not.a.real.url/programs This is only a test ** Anyone? Anyone? Thanks, Katherine -Original Message- From: ELLIOTT,KATHERINE A (HP-FtCollins,ex1) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 2:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Adding HTTP URL Code Hello, I have a string of data that can be anywhere from one line (a single URL) to many, many lines. The data is in plain text but, as I alluded, may contain one or more URLs (or none). I then take this data and put it on a web page so I would like to make any URLs in the data live. Has anyone on the list done this? If so, can you tell me how? I'm stumped. Thanks, Katherine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding HTTP URL Code
On Thursday 09 January 2003 04:07, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. With regards to your original query, the answer is in the archives. Try searching for something like regex url or regex hyperlink etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* NOTICE: alloc: /dev/null: filesystem full */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adding HTTP URL Code
On Wed, 8 Jan 2003, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. The follow-up inquery makes much more sense than the original ;) If I have a bunch of plain text data, how can I pull out the strings containing http. I've tried several different things but what I end up with is more or less than what I want. Once I have this, I can add the URL code and replace the string but I haven't figured out how to do this. Say that the paragraph you gave is a string in a variable, $TEXT ... $allowedChars = /:@\w.#~?%+=!-; preg_match_all( {\bhttp:[$allowedChars]+?(?=[$.:?\-]*[^$allowedChars]|$)}x, $TEXT, $URLS ); foreach( $URLS[0] as $link ){ print( a href=\${link}\${link}/a\n ); } That should get ya started. Read up on regular expressions, and the regexp functions in PHP to make heads tails out of the code, other than it works. (So far it works well for my intentionally limited purposes ... I wouldn't be surprised that someone finds a case where my code breaks, or someone can/does easily extend the regexp to grok more stuff.) http://www.oreilly.com/catalog/regex2/ http://www.php.net/manual/en/ref.pcre.php http://www.php.net/manual/en/ref.regex.php g.luck, ~Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding HTTP URL Code
I think the reason you didn't get a reply is because no one could understand what you wanted to happen my guess is... You need a regular expression to turn URLs in a string into links. So that this: --- This is a test. It is only a test. What happens when I include a URL in my results text? http://not.a.real.url/programs This is only a test --- becomes: --- This is a test. It is only a test. What happens when I include a URL in my results text? a href=http://not.a.real.url/programs;http://not.a.real.url/programs/a This is only a test --- Correct? Let us know, and I'm sure someone can help you out. FWIW it's been asked MANY times, so a search of the archives might help. Justin on 09/01/03 7:07 AM, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) ([EMAIL PROTECTED]) wrote: OK, so I've gotten NO responses to my query below so I thought I'd ask for something slightly different and see what I get. If I have a bunch of plain text data, how can I pull out the strings containing http. I've tried several different things but what I end up with is more or less than what I want. Once I have this, I can add the URL code and replace the string but I haven't figured out how to do this. For example, what would I do if my text looks like this (not including the astrices): ** This is a test. It is only a test. What happens when I include a URL in my results text? http://not.a.real.url/programs This is only a test ** Anyone? Anyone? Thanks, Katherine -Original Message- From: ELLIOTT,KATHERINE A (HP-FtCollins,ex1) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 2:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Adding HTTP URL Code Hello, I have a string of data that can be anywhere from one line (a single URL) to many, many lines. The data is in plain text but, as I alluded, may contain one or more URLs (or none). I then take this data and put it on a web page so I would like to make any URLs in the data live. Has anyone on the list done this? If so, can you tell me how? I'm stumped. Thanks, Katherine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php