MyBB Community Forums

Full Version: mySQL error: 1064
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I made a little script which I used with MyBB 1.0 PR2. When you change your domain the script searches in your posts for the old URL and replaces them with the new one. It worked perfertly.

But now I get the MySQL-Error 1064 everytime no matter what I try. Any ideas?

The Script:
<?php
require "./global.php";

// Hier URLs einsetzen
$url_alt = "http://www.url_alt.de";
$url_neu = "http://www.url_neu.de";

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts");
while($p = $db->fetch_array($query))
{
	$db->query("UPDATE ".TABLE_PREFIX."posts SET message='".$p['message'] = str_replace($url_alt, $url_neu, $p['message'])."' WHERE pid='".$p[pid]."'");
	echo "Aktualisiere Post ".$p['pid']."<br />\n";
}
?>
Try this:

<?php
require "./global.php";

// Hier URLs einsetzen
$url_alt = "http://www.url_alt.de";
$url_neu = "http://www.url_neu.de";

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts");
while($p = $db->fetch_array($query))
{
    $db->query("UPDATE ".TABLE_PREFIX."posts SET message='"addslashes(str_replace($url_alt, $url_neu, $p['message']))."' WHERE pid='".$p[pid]."'");
    echo "Aktualisiere Post ".$p['pid']."<br />\n";
}
?>
Thanks a lot! Big Grin