Hi all,
I have a table that has a large portion of the records with a field set to zero and the rest are null.
I want to do an update script, but cannot afford to lose any data.
The site is live and I cannot take it down, even temporarly.
The database is called 'Main'
The Table is called 'Forms'
And the field is called 'Washington'
I am doing a lookup for any field that has a value of '0' (zero) and want to set it to "" (null).
But before executing, I want to have a second set of eyes, look it over.
I will do an export of the table, but like I said, it is live and I will still lose some data.
Thanks,
Don
// connect to the db
$db = mysql_connect("localhost", "x", "x");
mysql_select_db("inthecla_vzpoll",$db);
// get all the records that need updated
$result = mysql_query("SELECT * FROM Forms Where Washington='0'",$db);
$null= "";
// update the records now
$sql ="UPDATE Forms SET Washington='$null' WHERE Washinton='0'";
if(!mysql_query($sql)){
echo mysql_errno().'<br>'.mysql_error().'<br><br>';
}
// echo finished
echo 'I'm done updating all the records that where set to 0";