php-general | 2001032
Date: 03/29/01
- Next message: Jon Haworth: "RE: [PHP] Best way to check if a query succeeded"
- Previous message: Sean Weissensee: "[PHP] Setcookie not working"
- Next in thread: David Robley: "Re: [PHP] [PHP-DB] ALTER TABLE - code not working."
- Reply: David Robley: "Re: [PHP] [PHP-DB] ALTER TABLE - code not working."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Jon Haworth: "RE: [PHP] Best way to check if a query succeeded"
- Previous message: Sean Weissensee: "[PHP] Setcookie not working"
- Next in thread: David Robley: "Re: [PHP] [PHP-DB] ALTER TABLE - code not working."
- Reply: David Robley: "Re: [PHP] [PHP-DB] ALTER TABLE - code not working."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

