TBDev Forum
Programming board
Main Page Forum Rules Privacy Policy Members Contact Us
Welcome Guest (Login | Register)
TBDev Forum TBDev.net - Help *nix based Installations help with php for repair database

help with php for repair database

2007-02-06 07:35:00
Group: Member
Posts: 158
Topics participated: 79
Topics started: 18
First post: 2006-03-10 22:20:00
Last post: 2007-11-24 19:37:00
Hi guys, i recently changed my tracker to a new server and im getting some errors in the db like 3 times per day... i run a repair from phpmyadmin and all fine again... the errors in the db as is shown in the tracker are in the torrents table and the news table... weird.

Well i got this php for repair:

php
require_once("include/secrets.php");
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$sql = "SHOW DATABASES";
$dbs_result = mysql_query($sql, $db);
if(mysql_num_rows($dbs_result))
{
while($dbs_row=mysql_fetch_assoc($dbs_result))
{
$database = $dbs_row["Database"];
echo "\n\nOptimizando y Reparando la base de datos: \n";
mysql_select_db($database, $db);
$sql = "SHOW TABLE STATUS";
$tbls_result = mysql_query($sql, $db);
if(mysql_num_rows($tbls_result))
{
while($tbls_row=mysql_fetch_assoc($tbls_result))
{
$TableName = "`".$tbls_row["Name"]."`";
$sql = "REPAIR TABLE ".$TableName;
echo "\n".$sql;
mysql_query($sql, $db);
$sql = "OPTIMIZE TABLE ".$TableName;
echo "\n".$sql;
mysql_query($sql, $db);
}
}
}
}
echo "\n\n";
mysql_close($db);
?>


But when i use this i get a error again...

Table './tracker/torrents' is marked as crashed and last (automatic?) repair failed


Can anyone help me giving me a simple php for repair the entire database and not need to login in phpmyadmin etc....... and with this any user of my staff could solve the problem if im not online.

Thanks guys!

PD: i use DR source.
 
2007-02-06 21:10:00
Group: Member
Posts: 137
Topics participated: 74
Topics started: 24
First post: 2006-10-12 20:44:00
Last post: 2009-01-01 16:14:00
think this one will help u?! it works for me:)

hehe sorry m8 don't know how i can miss ur code but this one works for me..
 
2007-02-06 21:21:00
Group: Member
Posts: 158
Topics participated: 79
Topics started: 18
First post: 2006-03-10 22:20:00
Last post: 2007-11-24 19:37:00
did you read me post? :D

that is what i posted... and it dont works in my tracker :(
 
2007-02-06 21:29:00
Group: Member
Posts: 373
Topics participated: 97
Topics started: 5
First post: 2006-12-08 14:16:00
Last post: 2008-08-25 19:10:00
Table './tracker/torrents' is marked as crashed and last (automatic?) repair failed


This table is an innodb table?
 
2007-02-06 22:07:00
Group: Member
Posts: 158
Topics participated: 79
Topics started: 18
First post: 2006-03-10 22:20:00
Last post: 2007-11-24 19:37:00
no, type MyISAM
 
2007-02-06 22:11:00
Group: Member
Posts: 373
Topics participated: 97
Topics started: 5
First post: 2006-12-08 14:16:00
Last post: 2008-08-25 19:10:00
try just a repair thing

mysql_query("REPAIR TABLE torrents");
 
2007-02-07 07:25:00
Group: Member
Posts: 158
Topics participated: 79
Topics started: 18
First post: 2006-03-10 22:20:00
Last post: 2007-11-24 19:37:00
just that in a php... will try it.

Thanks bro!

php
require_once("include/secrets.php");
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
mysql_query("REPAIR TABLE torrents");
?>


is allright?

btw, what if i want to repair the entire db and not only torrents table? any idea?
 

Similar threads

Topic Posts Last post
Optimize & Repair Database from Tracker 2 2008-03-06 12:27:00
Auto Repair Database with Cron jobs 4 2008-08-21 13:19:00
Need help with database or php! 14 2008-11-30 13:52:00
Simple ORM database mapping for PHP 1 2008-09-18 06:48:00
How can i repair this problem? 8 2008-05-22 17:30:00