/* these are the same settings as in dbconfig.php - i copied it right from there. so check that if you are unsure of your settings*/
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$dbname = 'database';
$mysql_access = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname, $mysql_access);
/*change to your table prefix found in config.php*/
$tableprefix = "your_table_prefix";
$stories_table = $tableprefix."fanfiction_stories";
/* change these to your new ratings */
$new_g = "new G";
$new_pg13 = "new PG13";
$new_pg = "new PG";
$get_story_rid = mysql_query("Select rid from $stories_table") or die(mysql_error() . " Check your table prefix");
while($rid = mysql_fetch_array($get_story_rid))
{
switch ($rid[rid])
{
/* change these switches to your existing ratings to coincide with $new_ variables */
case "NC-17":
mysql_query("update $stories_table set rid = '$new_g' where rid = \"NC-17\"") or die(mysql_error());
echo "Row $rid[id] updated from NC-17 to $new_g
";
break;
case "PG-13":
mysql_query("update $stories_table set rid = '$new_pg13' where rid=\"PG-13\"") or die(mysql_error());
echo "Row $rid[id] updated from PG-13 to $new_pg13
";
break;
case "X":
mysql_query("update $stories_table set rid = '$new_pg' where rid=\"X\"") or die(mysql_error());
echo "Row $rid[id] updated from X to $new_pg
";
break;
default:
echo "No changes made to the database.
";
}
}
echo "The script is complete, check your tables for any errors.";
?>