I don't understand why no updating is taking effect and no table is created:
PHP Code:
include("../files/constants.php");
include("../files/dbconnection.php");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($acronym."_book", $con);
$sql = "SELECT * FROM ".$acronym."_pages WHERE content LIKE '%nbsp%'";
$result = mysql_query($sql) OR exit( 'Error: ' . mysql_error() );
//echo $sql;
//to keep record of what changes are made I decided to create a table
$sql_record = "CREATE TABLE ".$acronym."_correction_nbsp
(
cor_ID int(6) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(cor_ID),
content_before longtext,
content_after longtext
)";
while($row = mysql_fetch_array($result)){
$new = preg_replace('#&?nbsp;?#i', ' ', $row['content']);
if($row['content'] != ""){
$sql_record2 = "INSERT INTO correction_nbsp (content_before, content_after)
VALUES (".$row['content'].", ".$new.")";
echo $sql_record2."<br />\n";
}
$sql2 = "UPDATE ".$acronym."_pages SET content = '".$new."' WHERE content = '".$row['content']."'";
echo $sql2."<br />\n";
}
mysql_close($con);
If you want to simply view the statements here are a few examples:
Code:
INSERT INTO correction_nbsp (content_before, content_after) VALUES ( CHAPTER 1 , CHAPTER 1 )
UPDATE bwas_pages SET content = ' CHAPTER 1 ' WHERE content = ' CHAPTER 1 '
INSERT INTO correction_nbsp (content_before, content_after) VALUES ( , )
UPDATE bwas_pages SET content = ' ' WHERE content = ' '
INSERT INTO correction_nbsp (content_before, content_after) VALUES ( , )
UPDATE bwas_pages SET content = ' ' WHERE content = ' '
INSERT INTO correction_nbsp (content_before, content_after) VALUES (chapter: , chapter: )
UPDATE bwas_pages SET content = 'chapter: ' WHERE content = 'chapter: '
INSERT INTO correction_nbsp (content_before, content_after) VALUES (copies  from  authoritative  sources  showing  the , copies from authoritative sources showing the )