Jump to content

[SOLVED] What's wrong here?


ShadeSlayer

Recommended Posts

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

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>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.