ALTER TABLE - code not working.
| From: | Martin E. Koss | Date: | Thu, 29 Mar 2001 11:20:41 +0000 |
| Subject: | ALTER TABLE - code not working. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7966@lists.php.net to get a copy of this message | ||
I have been trying to get a new column added to a table (vips) via a PHP
script, but having exhausted all the things I can find, I'm still
struggling. I've referred t TFM for all those who just can't wait to tell me
to do so, and believe my SQL statement is correct:
$NewCol = $Prod_Code;
$defaultvalue = "0.00";
// make usual connection
$conID = mysql_pconnect ("localhost","admin","mek1233");
mysql_select_db("FocusDynamics", $conID);
// set the query
$AddColQuery = "ALTER TABLE vips ADD COLUMN $NewCol";
$result = mysql_query ($AddColQuery,$conID);
// now set the default value for all rows in vips table
$SetDefault = "UPDATE TABLE vips SET $NewCol=$defaultvalue";
$result = mysql_query ($SetDefault,$conID);
It is NOT adding the column, and obviously not setting the default.
Any help would be great, thanks.
Martin.