Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


bbcode problem [PHP]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Mon Dec 29, 2008 2:15 pm    Post subject: bbcode problem [PHP] Reply with quote

i'm adding bbcode to a forum i'm working on

the
Code:
[url][/url]


ones are the ones i'm having trouble with

here is my code for them

Code:
"[url]" => "<a href=>",
"[/url]" => "</a>"


but it goes to the same page

any ideas???????

and i know...... I NEED TO LEARN 2 GRAMMAR


Last edited by deleted user 111213 on Mon Dec 29, 2008 3:01 pm; edited 2 times in total
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Mon Dec 29, 2008 2:22 pm    Post subject: Reply with quote

Look at the "target" parameter.
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Mon Dec 29, 2008 2:26 pm    Post subject: Reply with quote

i know about that, but what should i change it to?
Back to top
View user's profile Send private message
LolSalad
Grandmaster Cheater
Reputation: 1

Joined: 26 Aug 2007
Posts: 988
Location: Australia

PostPosted: Mon Dec 29, 2008 5:05 pm    Post subject: Reply with quote

http://www.w3.org/TR/REC-html40/struct/links.html

Neutral

_________________
Back to top
View user's profile Send private message MSN Messenger
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Mon Dec 29, 2008 7:23 pm    Post subject: Reply with quote

Erm, thats not how you do bbcode. If your making a forum or just adding bbcode, I suggest learning PHP first.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Tue Dec 30, 2008 12:20 am    Post subject: Reply with quote

ElectroFusion wrote:
Erm, thats not how you do bbcode. If your making a forum or just adding bbcode, I suggest learning PHP first.

Well since you're just "that good" at PHP. Why don't you actually help him instead of making some smart-ass rejoe. If you actually smart (which i doubt) then why don't you fucking help.

_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Tue Dec 30, 2008 3:22 am    Post subject: Reply with quote

i have actually learnt php, i'm just not that brilliant at it. i could borrow that book of my mate, but he lives 100 miles away, and hes the only other guy i know who knows php. and im not joking about the 100 miles away bit.
Back to top
View user's profile Send private message
compactwater
I post too much
Reputation: 8

Joined: 02 Aug 2006
Posts: 3923

PostPosted: Tue Dec 30, 2008 10:11 am    Post subject: Reply with quote

Your code would do this:

Code:
[url]http://www.google.com/[/url]
<a href=>http://www.google.com/</a>


I assume you want something like this:
Code:
[url=http://www.google.com/]Click here[/url]
<a href="http://www.google.com">Click here</a>
--or--
[url]http://www.google.com/[/url]
<a href="http://www.google.com/">http://www.google.com/</a>


Only the second would be possible with how you have it setup currently.

Fix:
Code:
"[url]" => "<a href=\"",
"[/url]" => "\">$link</a>"


Assuming $link contains the link.
However, a better option may be using preg_match/replace.
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Tue Dec 30, 2008 10:27 am    Post subject: Reply with quote

that code you gave me, didnt work. the posts wouldn't show up.(the ones with links in anyway)
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 30, 2008 1:20 pm    Post subject: Reply with quote

Code:
<?php
$string = "[url=http://www.google.com]lolwutgoogle[/url]";
$bbed = preg_replace('/\[url\=(.+)\](.+)\[\/url\]/', '<a href="$1">$2</a>', $string);
echo $bbed;
?>
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Tue Dec 30, 2008 1:36 pm    Post subject: Reply with quote

Reak wrote:
Code:
<?php
$string = "[url=http://www.google.com]lolwutgoogle[/url]";
$bbed = preg_replace('/\[url\=(.+)\](.+)\[\/url\]/', '<a href="$1">$2</a>', $string);
echo $bbed;
?>


could you possibly make it like,
Code:
$BBCode = array("&" => "&",
"<" => "<",
">" => ">",
"[b]" => "<b>",
"[/b]" => "</b>",
"[i]" => "<i>",
"[/i]" => "</i>",
"[u]" => "<u>",
"[/u]" => "</u>",
"[img]" => "<img src='",
"[/img]" => "'>",
"[code]" => "<font style=\"padding:3px;\" color=\"#CC0000\" size=\"2\">Code:</font><br><div id='code'><tt>",
"[/code]" => "</tt></div>");


but like just "[url]" so it fits into my array?
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 30, 2008 1:47 pm    Post subject: Reply with quote

Get a rid of string_replace or whatever you use.

Code:
<?php
$pregs = array(
   '/\[b\](.+)\[\/b\]/' => '<b>$1</b>',
   '/\[i\](.+)\[\/i\]/' => '<em>$1</em>',
   '/\[url\=(.+)\](.+)\[\/url\]/' => '<a href="$1">$2</a>'
);
$bold = preg_replace(array_keys($pregs), array_values($pregs), '[b]This is bold[/b]<br />');
$italic = preg_replace(array_keys($pregs), array_values($pregs), '[i]This is italic[/i]<br />');
$url = preg_replace(array_keys($pregs), array_values($pregs), '[url=http://www.google.de]This is an url[/url]<br />');

echo $bold.$italic.$url;
?>
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Tue Dec 30, 2008 1:53 pm    Post subject: Reply with quote

i mean like in the same format i have done mine in

so like

Code:
"[url]" => "<a href=>",
"[/url]" = > "</a>"


but what do i put in between the <a href> bit?
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 30, 2008 3:05 pm    Post subject: Reply with quote

Yea I know what you meant.
But you should get a rid of str_replace and use the code I posted.
It's much better.
I already added [i] and [b], so you can simply add other bbcodes like [u] or [img]..
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Tue Dec 30, 2008 3:12 pm    Post subject: Reply with quote

how do i change [url= to just [url] please. thx for the code. but the [url= thing is annoying to use for me.

edit:also that kind of code is annoying. hard to edit. plus i dont know how to modify it into user input. ill show you my whole function.

2nd edit: that code doesn't work for me. it turns my website all wierd. so please use the array and function i supplied below the sentence. cause i have i tried that stuf and it has never worked for me.

Code:
function topic($input){

$BBCode = array("&" => "&amp;",
"<" => "&lt;",
">" => "&gt;",
"[b]" => "<b>",
"[/b]" => "</b>",
"[i]" => "<i>",
"[/i]" => "</i>",
"[u]" => "<u>",
"[/u]" => "</u>",
"[img]" => "<img src='",
"[/img]" => "'>",
"[code]" => "<font style=\"padding:3px;\" color=\"#CC0000\" size=\"2\">Code:</font><br><div id='code'><tt>",
"[/code]" => "</tt></div>",
"[url]" => "<a href=>",
"[/url]" => "</a>");

$parsedtext = str_replace(array_keys($BBCode), array_values($BBCode), $input);
return nl2br($parsedtext);

return nl2br(strip_tags(stripslashes(htmlspecialchars($input))));

}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites