Jump to content

Whats wrong with this code?


gibigbig

Recommended Posts

$search  	 = $_POST['search'];
$replace	 = $_POST['replace'];
$zero = 0;
$gibs = mysql_query("SELECT * FROM anime"); 
while ($gib = mysql_fetch_assoc($gibs)) {
	$new_description[] = str_replace($search,$replace,$gib['description']);
	$new_history[]	 = str_replace($search,$replace,$gib['history']);
	$anime_id[] = $gib['anime_id'];
	$numberlinks		= ++$zero;
}

	for($i=0; $i<$numberlinks; $i++) {
		$thequery[] = mysql_query("UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'");
	}
	foreach ($thequery as $query){
				mysql_query($query) or die (mysql_error());
				echo "<span style='color:green'>Edited sucessfully <b>Anime ".++$one."</b> </span><br/>";
		} 

echo "<meta http-equiv='refresh' content='2;url=http://www.website.com/forums/downloads-manager.php?task=fix-descriptions'>";

 

output:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

 

Inputs:

$search: 

$replace:  "

Link to comment
https://forums.phpfreaks.com/topic/214371-whats-wrong-with-this-code/
Share on other sites

change

$thequery[] = mysql_query("UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'");

to

$thequery[] = "UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'";

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.