gibigbig Posted September 25, 2010 Share Posted September 25, 2010 $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 More sharing options...
kenrbnsn Posted September 25, 2010 Share Posted September 25, 2010 Echo your query when you get an error, so you can see what caused the problem: <?php mysql_query($query) or die ("Problem with the query: $query<br>" . mysql_error()); ?> Ken Link to comment https://forums.phpfreaks.com/topic/214371-whats-wrong-with-this-code/#findComment-1115578 Share on other sites More sharing options...
sasa Posted September 26, 2010 Share Posted September 26, 2010 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]."'"; Link to comment https://forums.phpfreaks.com/topic/214371-whats-wrong-with-this-code/#findComment-1115785 Share on other sites More sharing options...
gibigbig Posted September 26, 2010 Author Share Posted September 26, 2010 Thank you very much sasa worked perfectly *hugs* Link to comment https://forums.phpfreaks.com/topic/214371-whats-wrong-with-this-code/#findComment-1115836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.