I just executed my php script and got the following error. I’m unsure what it means or how I fix it.
A fatal MySQL error occured.
Query:
Error: (126) Incorrect key file for table ‘/ramdisk/mysql/tmp/#sql_5ec4_1.MYI’; try to repair it
Here is a copy of my simple script that goes through a few database tables blowing away spam entries and such. Can someone help me decipher this error?
Thanks!
<?php
include 'toolsHeader.php';
include 'db.inc.php';
$today = date("Y-m-d h:i:s");
//////////////////////////////////////////////////////////////////
//Delete the spam emails that were added by spambots
//////////////////////////////////////////////////////////////////
$spamSQL = "select count(*) as total from notifications where sender = 'Unknown'";
$results = mysql_query($spamSQL) or die(mysql_error());
$row = mysql_fetch_assoc($results);
$totalSpam = $row['total'];
if ($totalSpam > 0) {
$spamNuker = "delete FROM notifications WHERE sender = 'Unknown'";
$result = mysql_query($spamNuker) OR die(mysql_error());
}
else {
$totalSpam = "0";
}
//////////////////////////////////////////////////////////////////
//Delete bogus testimonials that were posted
//////////////////////////////////////////////////////////////////
$testimoniesSQL = "select count(*) as total from testimonies where author = '0'";
$results = mysql_query($testimoniesSQL) or die(mysql_error());
$row = mysql_fetch_assoc($results);
$totalTestimonies = $row['total'];
if ($totalTestimonies > 0) {
$testimoniesNuker = "delete FROM testimonies WHERE author = '0'";
$result = mysql_query($testimoniesNuker) OR die(mysql_error());
}
else {
$totalTestimonies = "0";
}
//////////////////////////////////////////////////////////////////
//Delete bogus accounts that were posted
//////////////////////////////////////////////////////////////////
$usersSQL = "select count(*) as total FROM `users` where firstname = lastname";
$results = mysql_query($usersSQL) or die(mysql_error());
$row = mysql_fetch_assoc($results);
$totalUsers = $row['total'];
if ($totalUsers > 0) {
$usersNuker = "delete FROM users WHERE firstname = lastname or zip = '123456'";
$result = mysql_query($usersNuker) OR die(mysql_error());
}
else {
$totalUsers = "0";
}
//////////////////////////////////////////////////////////////////
//Compose an email that tells how much spam was deleted overall
//////////////////////////////////////////////////////////////////
if ($totalSpam > 0 OR $totalTestimonies > 0 OR $totalUsers > 0) {
$type = "Spam Removal";
$sender = "support@oil-testimonials.com";
$recipient = "robert@recordaudio.net";
$subject = "Total purged spam";
$message = "The following spam was removed from the database:
Emails where sender was unknown: $totalSpam
Testimonials with author set to zero: $totalTestimonies
Bogus user accounts: $totalUsers";
$createEmail = "INSERT INTO notifications (date, priority, type, sender, recipient, subject, message) VALUES (
'$today',
'2',
'$type',
'$sender',
'$recipient',
'$subject',
'$message')";
mysql_query($createEmail) OR die("<b>A fatal MySQL error occured</b>.\
<br />Query: " . $createEmail . "<br />\
Error: (" . mysql_errno() . ") " . mysql_error());
}
else {
print ("<p>There were no spam emails to process at ths time.</p>");
}
//////////////////////////////////////////////////////////////////
//Pull emails out that need to be sent, based on priority
//////////////////////////////////////////////////////////////////
$getEmails = "SELECT u.firstname, u.lastname, n.nID, n.date, n.priority, n.type, n.sender, n.recipient, n.subject, n.message FROM users u, notifications n WHERE sent is null order by priority limit 5";
$result = mysql_query($getEmails) OR die("<b>A fatal MySQL error occured</b>.\
<br />Query: " . $createEmail . "<br />\
Error: (" . mysql_errno() . ") " . mysql_error());
if ($row = mysql_fetch_array($result)) {
do {
$firstname =$row["firstname"]; // Firstname of the one sending the email
$lastname =$row["lastname"]; // Lastname of the one sending the email
$nID =$row["nID"]; // ID of the stored email
$type =$row["type"]; // The type of email going to be sent
$date =$row["date"]; // The date it was put into DB
$sender =$row["sender"]; // Address of sender
$recipient =$row["recipient"]; // Address of receiver
$subject =$row["subject"]; // Subject of the email to go out
$message =$row["message"]; // Message of the email
$senderName = "$firstname $lastname";
$senderEmail = "$email";
if ($senderEmail == "support@oil-testimonials.com") {
$senderName = "Support Team";
}
$message = stripslashes($message);
$subject = stripslashes($subject);
print ("nID = $nID, $date, $type, $recipient<br>");
$headers = "From: $senderName <$senderEmail>\\r\
";
$headers .= "Reply-To: $senderEmail\\r\
";
mail($recipient, $subject, $message, $headers);
//////////////////////////////////////////////////////////////////
//Update the row to indicate the email has been sent
//////////////////////////////////////////////////////////////////
$updateRows = "UPDATE notifications SET sent = '$today' where nID = $nID";
mysql_query($updateRows) OR die("<b>A fatal MySQL error occured</b>.\
<br />Query: " . $createEmail . "<br />\
Error: (" . mysql_errno() . ") " . mysql_error());
} while($row = mysql_fetch_array($result)); //End DO loop
} // End getting results from the getEmails query
include 'toolsFooter.php';
?>