Re-name Table to a Variable

[FONT=“Georgia”]Hi.

I’m trying to set up an auto back-up thing on a database table.

I’d like the back-up name to be the table’s name, then a space, and the date and timestamp.

The following syntax isn’t working though. Can anyone advise how it should be done instead?[/FONT]

/* Re-name the Current Table as a Back Up */

	// Connect to Database
		@ include($_SERVER['DOCUMENT_ROOT'] . '/protected/table-info.php');
		@ mysql_connect($db_Host,$db_Username,$db_Password);
		@ mysql_select_db($db_Database) or die("Server too busy. Please try again later.");

	// Re-name Table
		$backup_name = 'yellow_categories ' . date('Y-m-d') . '_' . time();
		$query = "RENAME TABLE yellow_categories TO $backup_name";
		mysql_query($query);

	// Dis-connect from Database
		@ mysql_close();

[FONT=“Georgia”]Thanks, but it didn’t work.

I think it’s something to do with the dashes in the date(); part. When I change $backup_name to just ‘yellow_categories’ and a timestamp, it works just fine.

That’ll do though.

Thanks a lot.

[/FONT]

Try:

/* Re-name the Current Table as a Back Up */ 
    // Connect to Database        @ include($_SERVER['DOCUMENT_ROOT'] . '/protected/table-info.php');        @ mysql_connect($db_Host,$db_Username,$db_Password);        @ mysql_select_db($db_Database) or die("Server too busy. Please try again later."); 
    // Re-name Table        $backup_name = 'yellow_categories ' . date('Y-m-d') . '_' . time();        $query = "RENAME TABLE yellow_categories TO '$backup_name'";        mysql_query($query); 
    // Dis-connect from Database        @ mysql_close();

[FONT=“Georgia”]I also tried it without the space, by the way, and that version didn’t do anything either.

[/FONT]