Ok, I need some help on the code I have already written.. This is the code..
// Get everything after <message #$u>
$mess = explode ('<message #'.$u.'>', $content);
// Get everything before <message #$u>
$mess = explode ('</message #'.$u.'>', $mess[1]);
// Set $message, as the current message!
$message = $mess[0];
// Get everything after certain tags
$sender = explode ('<sender>', $message);
$body = explode ('<body>', $message);
$subject = explode ('<subject>', $message);
// Get everything before certain tags
$sender = explode ('</sender>', $sender[1]);
$body = explode ('</body>', $body[1]);
$subject = explode ('</subject>', $subject[1]);
// Add slashes so it doesnt screw up our query!
$sender = addslashes ($sender[0]);
$subject = addslashes ($subject[0]);
$body = addslashes ($body[0]);
// Insert data into the MySQL database!
$query = "INSERT INTO $dbtabl VALUES ('', '$subject', '$sender', '$body', '$threadid')";
mysql_query($query);
$u++;
[/SIZE]I have a file which has messages organized in this way:
<message #1>
<ts>lalsalal</ts>
<sender>Daggeth</sender>
<subject>Problem with script</subject>
<body>This is my problem</body>
</message #1>
<message #2>
<ts>lalsalal</ts>
<sender>So on</sender>
<subject>There are other messages</subject>
<body>The messages continue...</body>
</message #2>
As you can see, my script parses through the file and inserts the data into the MySQL database. The problem I am facing is that my script is removing the indentations in the messages. Big nono! It is jumbling everything together. Another thing, is there a way to make the code less confusing? thanks in advance!
By The Way: The script is in a for loop 🙂