ALTER TABLE - code not working.
| From: | Martin E. Koss | Date: | Thu, 29 Mar 2001 11:48:20 +0000 |
| Subject: | ALTER TABLE - code not working. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-46077@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 to TFM for all those who just can't wait to tell
me
to do so, and I 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
// According to the mySQL manual:
// ALTER TABLE vips ADD column_name FLOAT (11,2) DEFAULT '0.00'
// So I used:
$AddColQuery = "ALTER TABLE vips ADD $NewCol FLOAT (11,2) DEFAULT '0.00'";
$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.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net