RockyLouZ Posted September 8, 2009 Share Posted September 8, 2009 To start off here is my code... <? require_once("classes.php"); require_once("dbcon.php"); function displayInfo($the_userid) { $Duser = new User($the_userid); $the_info = " <br> $Duser->formattedname ($the_userid) $Duser->cityname $Duser->formattedonline <br> "; return $the_info; } $text = "Results for player [user]566[/user]"; $text = eregi_replace("\\[user]([^\\[]*)\\[/user\\]"," ". displayInfo("\\1") ." ",$text); echo"$text"; ?> The problem is that when I am passing the variable \\1, it echos it correctly with the variable "$the_userid" which is 566. But when I use a query to select the information, or use a class to define the user, it treats the variable as one. $Duser->formattedname ($the_userid) $Duser->cityname $Duser->formattedonline All the info that I echo with the class Duser is selecting info from the user with an id of one. But the ($the_userid) displays as 566. Ive tried using $the_userid = (int)$the_userid but it sets the userid to 0 then. Ive worked on this for hours and can't seem to find out what the dang problem is. I'm sure it's something minor, there can't be much more to it. I also need to use the eregi_replace function to replace all instances of [user]. If anyone can help me out it would be greatly appreciated. Thanks! Lou Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/ Share on other sites More sharing options...
micmania1 Posted September 8, 2009 Share Posted September 8, 2009 You have displayInfo("\\1"). Change '1' to the user id (566) and remove the slashes. Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/#findComment-914759 Share on other sites More sharing options...
RockyLouZ Posted September 8, 2009 Author Share Posted September 8, 2009 \\1 is a variable for the information between [user] [/user]. Yeah replacing it with 566 would make the function work but it defeats the purpose of the bbcode. Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/#findComment-914769 Share on other sites More sharing options...
RockyLouZ Posted September 8, 2009 Author Share Posted September 8, 2009 bump^^ Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/#findComment-914823 Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 Try $text = "Results for player [user]566[/user]"; $text = preg_replace("/\[user\](.*)\[\/user\]/e", "displayInfo('\\1')", $text); Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/#findComment-914863 Share on other sites More sharing options...
RockyLouZ Posted September 8, 2009 Author Share Posted September 8, 2009 Wow you are a life saver! lol it worked. Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/173541-problem-with-my-own-bbcode/#findComment-914981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.