SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 24th, 2002, 01:17 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Code problem

So,this is my first problem in php.
I have script for replace bb code in to html,for HTML links this is like this:
Code:
$novica = ereg_replace(
"([-_./a-zA-Z0-9!&%#?,'=:~]+)",
"(<a href="\1">\1</a>", $novica);


Ewerything works fine, but how can i open this link in new window?

Reply With Quote
  #2  
Old July 24th, 2002, 01:35 PM
DeVeRaS DeVeRaS is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Portugal
Posts: 31 DeVeRaS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to DeVeRaS
RE: Code problem

You can use Javascript for it.
Or you can pass a var by get and sent it to a script here you have Header ( location : http://domain.whatever/pagetoopen.php);

be well.

Reply With Quote
  #3  
Old July 24th, 2002, 02:06 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Code problem

If you want a link to open in a new window when someone clicks on it, just add the target parameter, i.e.:

<a href="http://codewalkers.com/" target="_blank">Click here!</a>


Reply With Quote
  #4  
Old July 24th, 2002, 05:36 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Code problem

I understand this with target="_blanc". Butt, how can I define this in my code or maybe better wher.
Ereg_replace function automatic replace bb code with html and i so I have something like www.domain.com.
All I wont is this link like www.domain.com opens in new window.

Here on Codewalker index page you have news.Last news is for Enterprise php. When I click on link in this news Enterprise php pege opens in new window, butt old Codewalkers windew stey.

OK, I hope you get the point of my problem.

BTW, sorry for my bad english.

Reply With Quote
  #5  
Old July 24th, 2002, 05:40 PM
DeVeRaS DeVeRaS is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Portugal
Posts: 31 DeVeRaS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to DeVeRaS
RE: Code problem

trie: <a href="http://www.domain.com/index.php" target="_blank">Click here</a>

Reply With Quote
  #6  
Old July 24th, 2002, 06:07 PM
miska99 miska99 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 miska99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Code problem

I thing you dont understand my problem. Look, this is my php code:

$news = ereg_replace(
"([-_./a-zA-Z0-9!&%#?,'=:~]+)",
"(<a href="\1">\1</a>", $news);

This code automatic replace bb code with html code for links, so when i wrote bb code for link i becomme on my screen something like www.domain.com.
Ewerything fine.
Problem here is, i want this link open in new window. What is missing in php code.

Reply With Quote
  #7  
Old July 24th, 2002, 06:11 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Code problem

try:

$news = ereg_replace(
"([-_./a-zA-Z0-9!&%#?,'=:~]+)",
"(<a href="\1" target="_blank">\1</a>", $news);

Reply With Quote
  #8  
Old July 24th, 2002, 06:20 PM
miska99 miska99 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 miska99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Code problem

dont work
Parse error: parse error, unexpected '('

Reply With Quote
  #9  
Old July 24th, 2002, 06:38 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Code problem

Ahh, the problem is that this forum is parsing the url tags you have in your ereg statement..check this text file for how it should be:

http://codewalkers.com/ereg.txt

Reply With Quote
  #10  
Old July 24th, 2002, 06:48 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: Code problem

php Code:
Original - php Code
  1. <?
  2. $news = ereg_replace("([-_./a-zA-Z0-9!&%#?,'=:~]+)","(<a href="\1" target="_blank">\1</a>", $news);
  3. ?>

is the correct code.. it had too many slashes.

Reply With Quote
  #11  
Old July 24th, 2002, 06:52 PM
miska99 miska99 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 miska99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Code problem

Matt, its nothing wrong with this code. It works fine.
Butt not open a link in new window.

Reply With Quote
  #12  
Old July 24th, 2002, 06:55 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Code problem

The ereg_replace statement in that text file produces a link that opens in a new window for me. It creates a link that has a target="_blank" property, which will open a new window...

Reply With Quote
  #13  
Old July 24th, 2002, 07:00 PM
miska99 miska99 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 miska99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Code problem

Matt, this is OK.
Ereg replace produses a new window link.
Lets say diferent. I have news page with link in it. Wenn i click on link new window opens, butt old page with news stays alive.
:cool

Reply With Quote
  #14  
Old July 24th, 2002, 08:17 PM
ASk ASk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 12 ASk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Code problem

i did it with very unefficient but working method

search for [ url ]
search for [ /url ]
(edit) you really need to add No BBCode parsing feature. Remove the extra spaces.(/edit)
take the string between two
use <a href="<?=$str?>"><?=$str?></a>



messy but works fine. I do need to learn RegExp sometime soon

Reply With Quote
  #15  
Old July 24th, 2002, 08:52 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Code problem

Now, it works
CODE

Code:
$novica = ereg_replace("([-_./a-zA-Z0-9!&%#?,'=:~]+)","(<a href="\1" target="_blank">\1</a>", $novica);


Thanx to all.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Code problem


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 |&nb