Home : General : Internet Technologies :

General: Internet Technologies: Re: [hennagaijin] Breaking Up a Line using PHP: Edit Log

Here is the list of edits for this post
Re: [hennagaijin] Breaking Up a Line using PHP
I only wish I knew what you guys were talking about :P

However, another new problem has risen. While I was adding strings to the database with a script I've written, some lines (I'm guessing) that contain ' or " are not being added because of syntax errors. I have tried "addslashes()" to it however when I do that I'm losing all the values from the array. Here's what I've got:

Code:
<html>
<body> <table width="100%" border="1">
<?

// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}

// Select the presenttruth database
if (! @mysql_select_db("presenttruth") ) {
echo( "<p>Unable to locate the presenttruth" . "database at this time.</p>" );
exit();
}



$ot_load = file("OT01.txt");

$ot_text = addslashes($_POST['ot_load']);

for ($index=0; $index < count($ot_text); $index++) {
$text = explode(":", chop($ot_text[$index]));

$addsql = "INSERT INTO Bible SET
bible_book='$text[0]',
bible_chap='$text[1]',
bible_verse='$text[2]',
bible_text='$text[3]'";

echo("<tr><td>" . $text[0] . "<br /></td>");
echo("<td>" . $text[1] . "<br /></td>");
echo("<td>" . $text[2] . "<br /></td>");
echo("<td>" . $text[3] . "<br /></td></tr>");




if (@mysql_query($addsql)) {
echo("<h5>Info added successfully.</h5>");
} else {
echo("<h5>Error adding info: " . mysql_error() . "</h5>");
}
}

?>

</table>
</html>



The $text output is just for debugging purposes so you can ignore that.

Last edited by:

JoFrRi: Aug 26, 2003, 3:06 PM

Edit Log: