ShadeSlayer Posted May 10, 2009 Share Posted May 10, 2009 This is the same script from the Regex board, but since I no longer am having regex problems, I've decided to make a new thread here. Here's my code: <?php include("common.php"); echo "<textarea style=\"width: 100%; height: 100px;\" name=\"\" value=\"\" readonly=\"readonly\">"; $tid = 29382; $id = 0; $sql = "SELECT threadid, body FROM ".TABLE_POSTS." WHERE threadid = ".$tid." ORDER BY threadid ASC"; if ($exe = runQuery($sql)) { while ($row = fetchResultArray($exe)) { $f[0] = "[b]"; $r[0] = "<b>"; $f[1] = "[/b]"; $r[1] = "</b>"; $f[2] = "[adminbr]"; $r[2] = "<br />"; $f[3] = "[i]"; $r[3] = "<i>"; $f[4] = "[/i]"; $r[4] = "</i>"; $f[5] = "[bq]"; $r[5] = "<blockquote>"; $f[6] = "[/bq]"; $r[6] = "</blockquote>"; $f[7] = "\n"; $r[7] = "<br />"; $f[8] = "\\\""; $r[8] = "\""; $f[9] = "\'"; $r[9] = "'"; preg_match('#(?:\[b\]|<b>)(.+?)(?:\[/b\]|</b>)#', $row['body'], $m); $i['title'] = $m[1]; $i['body'] = str_replace($f, $r, $row['body']); echo "INSERT INTO pxb_achievments (ID, date, title, content) VALUES (".$id.", ".$date("U").", '".$i['title']."', '".$i['body']."');\n"; $i++; } } echo "</textarea>"; ?> The purpose is to make a textarea with a bunch of database information inside. (INSERT INTO ...). There is no code here that would actually insert the info to a database, it's just echoing it on to a page. What the script is displaying, is an empty textarea. All of the info it should be printing is simply ignored. Link to comment https://forums.phpfreaks.com/topic/157550-solved-whats-wrong-here/ Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Maybe it's just me, but is there a reason for having the arrays $f and $r inside the while loop? Their values never change. You're just defining them per iteration, which is a waste. Are you supposed to echo that SQL? And what does $i++ do there? Link to comment https://forums.phpfreaks.com/topic/157550-solved-whats-wrong-here/#findComment-830716 Share on other sites More sharing options...
ShadeSlayer Posted May 10, 2009 Author Share Posted May 10, 2009 Ah. That $i should be $id. And I moved the other things out side of the loops. It still doesn't work, though. <?php include("common.php"); echo "<textarea style=\"width: 100%; height: 100px;\" name=\"\" value=\"\" readonly=\"readonly\">"; $f[0] = "[b]"; $r[0] = "<b>"; $f[1] = "[/b]"; $r[1] = "</b>"; $f[2] = "[adminbr]"; $r[2] = "<br />"; $f[3] = "[i]"; $r[3] = "<i>"; $f[4] = "[/i]"; $r[4] = "</i>"; $f[5] = "[bq]"; $r[5] = "<blockquote>"; $f[6] = "[/bq]"; $r[6] = "</blockquote>"; $f[7] = "\n"; $r[7] = "<br />"; $f[8] = "\\\""; $r[8] = "\""; $f[9] = "\'"; $r[9] = "'"; $tid = 29382; $id = 0; $sql = "SELECT threadid, body FROM ".TABLE_POSTS." WHERE threadid = ".$tid." ORDER BY threadid ASC"; if ($exe = runQuery($sql)) { while ($row = fetchResultArray($exe)) { preg_match('#(?:\[b\]|<b>)(.+?)(?:\[/b\]|</b>)#', $row['body'], $m); $i['title'] = $m[1]; $i['body'] = str_replace($f, $r, $row['body']); echo "INSERT INTO pxb_achievments (ID, date, title, content) VALUES (".$id.", ".$date("U").", '".$i['title']."', '".$i['body']."');\n"; $id++; } } echo "</textarea>"; ?> Link to comment https://forums.phpfreaks.com/topic/157550-solved-whats-wrong-here/#findComment-830719 Share on other sites More sharing options...
ShadeSlayer Posted May 10, 2009 Author Share Posted May 10, 2009 Bah. I found my problem. $date("U")[code=php:0] I hate little things like that. Link to comment https://forums.phpfreaks.com/topic/157550-solved-whats-wrong-here/#findComment-830737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.