Jump to content

teomanersan

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

teomanersan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. no i`m not trying to make bbcode.. i`m trying to convert bbcode into html equivalent.. thx :)
  2. hi guys.. i am using two bbcode tags for linking inside my site which are [bkz] [/bkz] and [bkz] [*bkz] for this, i'm using this code.. [code] $comment = preg_replace("#\[bkz](.*?)\[/bkz\]#ise", "'<a title=\"(bkz.\\1)\" href=\"ajaxcomsayfa.php?ara='.urlencode('\\1').'\">\\1</a>'",$comment); $comment = preg_replace("#\[bkz](.*?)\[\*bkz\]#ise", "'<a title=\"(bkz.\\1)\" href=\"ajaxcomsayfa.php?ara='.urlencode('\\1').'\" >*</a>'",$comment); [/code] works fine.. but now i want to convert bbcode to html.. so i used preg_replace again.. [code] $comment = preg_replace("#(<a title=(.+?) href=(.+?) >(.+?)</a>)#is","[bkz]\\1[/bkz]",$comment); $comment = preg_replace("#(<a title=(.+?) href=(.+?) >\*</a>)#is","[bkz]\\1[/*bkz]",$comment); [/code] now the problem starts ... it gives the output like this IF i use $comment = striptags($comment) and both tags were used.. [bkz][bkz]test*[*bkz][/bkz] if only one tag is used, nothing shows up :(( else it gives tags plus the html codes and drives me NUTS !!!! please if anyone know how to get rid of this problem, let me know !!! basicly what i want is: <a title="(bkz.test)" href="ajaxcomsayfa.php?ara=test">test</a> TO -> [bkz]test[/bkz] <a title="(bkz.test)" href="ajaxcomsayfa.php?ara=test">*</a> TO -> [bkz]test[*bkz] thanx for your time and any help is HIGHLY appericiated.. good coding
  3. ok i figured out it and did something like this and it works.. [code] $string = preg_replace("#\[star](.*?)\[/star\]#ise", "'<a href=\"/blabla.php?ara='.urlencode('\\1').'\" >*</a>'",$string); [/code] i need a reference manual something to sort out this syntax problems, any link / help is highly appericiated.. thx for ur time.. good coding..
  4. $query=mysql_query("select * from ******* where opening like '%$query%' or body_text like '%$query%'") or die(mysql_error()); if u dont want a null character results nothing , simply add a check control if($query == "") { echo('error'); } by the way i didn`t get the idea why u used OR in the sql statement because if it will find at opening it will pass body_text.. good coding..
  5. $page = 1; $numberpage = 40; // this was my mistake i wrote num[b]b[/b]er $min = ($page * $numperpage - $numperpage); $max = ($page * $numperpage - 1); echo($min); echo('<br>'); echo($max); so it gave 0 , -1 anyway thats not the deal.. my point is using your sql statement... you want 40 results for everypage, so $max should be 40, it shoud be fixed because in sql query, like select bla bla from bla bla where bla bla LIMIT 20,40 -> this means starting from 21st , get the next 40 results lets check for page-> 2 $min = 40; $max = 79; then it will bring starting from 41st, next 79 records.. this is what i wanted to mention.. good coding..
  6. dude.. your $min and $max values are not mathematically correct.. let`s check the results for page = 1; min = 0; max = -1; so how is it possible to get a guery like select from bla bla where bla bla limit 0,-1 -> which means get me first -1 results starting with 1st this is absurd.. set $max = 40 and it should solve the problem unless u want a dynamic max which changes for the selected $page -> for e.g. odd numbers show 10 results , evens show 20 results etc.. good coding..
  7. try this.. i didnt check it but if it`s not working u should check ur counters etc.. $min = ($page -1 ) * $numberpage; $max = $numberpage; hope this helps.. good coding
  8. $query=mysql_query("select * from ******* where opening like '%$query%' or body_text like '%$query%' [b]LIMIT 5[/b]") to limit the query results.. hope this helps.. good coding..
  9. after you made the necessary settings (for.e.g checking user name and password is OK ) you have to add a unique variable to the user session such as <? $_SESSION['user'] = $user_info['nick']; ?> where $_SESSION['user'] is the variable which holds the nickname of the logged user as the session variable, $user_info['nick'] is the nickname of the user which is the user`s nick fetched from database (of course before assigning the session u have to make the necessary checks else it will cause security problems) in every page you have to get unique data`s for the logged member: <? session_start() ; // start the session , let`s check if member is logged properly if(isset($_SESSION['user'] == FALSE) // if this member is not authorized ? { include_once('login.php'); // show login page for authorization } else { // fetch necessary data u`d like.. u can assign $_SESSION['nick'] to a variable and use it in your sql queries , } hope this helps.. good coding
  10. [!--quoteo(post=386337:date=Jun 21 2006, 02:06 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 21 2006, 02:06 PM) [snapback]386337[/snapback][/div][div class=\'quotemain\'][!--quotec--] You'll want to use the e modify like so: $string = preg_replace('#\[star](.*?)\[/star\]#ise','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string); [/quote] thanks a lot for the reply but this code is not working.. i googled this problem and couldn`t find much and the ones i found didnt work :( please, i need help about this problem.. thx for ur time good coding..
  11. hi guys.. i`d like to ask how to accomplish using urlencode() function inside a preg_replace function and inverse of preg_replace.. $string = preg_replace('#\[star](.*?)\[/star\]#is','<a href="blabla.php?ara=\\1">*</a>',$string); works fine.. but i have to add a urlencode() to the link... so i tried some stuff like below $string = preg_replace('#\[star](.*?)\[/star\]#is','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string); which is not working.. it`s encoding \\1 and not the $string.. how can i make it encode the string ?? the second question is how can i take the inverse of this preg_replace().. simply when i get $string = <a href="blabla.php?ara=\\1">*</a>' , i want it to write [star]$string[/star] thanks for your time.. good coding..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.