General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 15th, 2003, 01:28 AM
weisim weisim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 11 weisim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
making http:// clickable

OK, here's my problem at the moment, i've written a basic msg board using php and mySQL, and basically everytime u post to the board, it'll write an entry into the database. Here's my problem. I want to make my message board such that every time someone types:

http://something

it'll convert it into:

<a href=http://something>something</a>

I've tried something along the lines of

$result = mysql_query("SELECT * , REPLACE ( comment, 'http://%', '<a href=http://%>http://%</a>' )comment_link FROM db");


but that doesn't work... can anyone please tell me how I'd be able to go about doing it please? thanQ!

Reply With Quote
  #2  
Old December 15th, 2003, 03:37 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Is it a single line field or multiple line?

Reply With Quote
  #3  
Old December 15th, 2003, 08:05 PM
weisim weisim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 11 weisim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ermm... what do you mean? like, I use a text area to input the text, so I guess it's a multipleline field, if that's what you mean?

Reply With Quote
  #4  
Old December 17th, 2003, 02:17 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
What happens if you change http://something to http://something/ or http://something/index.htm (or .php) ? try that, might work...

Reply With Quote
  #5  
Old December 17th, 2003, 03:30 AM
weisim weisim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 11 weisim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hrmm...? I don't really get what you mean nicat23...

Reply With Quote
  #6  
Old December 17th, 2003, 05:42 AM
Ara-Tech Ara-Tech is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 Ara-Tech User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
use regular Expressions ..
best regards

Reply With Quote
  #7  
Old December 18th, 2003, 10:58 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
In your code, do you have the final forward slash at the end of the url? For example, you said that you have it as
Code:
http://something
without the final / at the end of something

what happens if you include a final / at the end of something like this
Code:
http://something/
?

Reply With Quote
  #8  
Old December 20th, 2003, 07:42 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
Have you thought to use tags, like these forums use [ url ] and [ /url ] (no spaces),
something like that for a use to define a link, then in php replace every instance of
[ url ] with '<a href="' and
[ /url ] with '">click here</a>' for example,
or do you want it to auto detect URLs without the user specifying that it should be a url?

Remember if you auto detect URLs this may not be what the user is expecting, they may prefer to specify urls in some manner,
how ever should you wish to detect URLs auto then I would reccomend doing it with with php, not within an SQL command.

Reply With Quote
  #9  
Old December 27th, 2003, 09:42 PM
weisim weisim is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 11 weisim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
THanks Peoples, yeahp I used regular expressions and it's all working now!!!

Reply With Quote
  #10  
Old December 28th, 2003, 12:10 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I'm curious to see the code you've used... if its not too big, could ya post it here?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > making http:// clickable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT