RE: [PHP-DB] ALTER TABLE - code not working.
> -Original Message- > From: Martin E. Koss [mailto:[EMAIL PROTECTED]] > Sent: 29 March 2001 15:32 > To: Manuel Lemos; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] ALTER TABLE - code not working. > $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); > I believe you SQL is wrong, you forgot to set the column type. ie. ALTER TABLE vips ADD COLUMN $NewCol VARCHAR(32) etc M@ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] ALTER TABLE - code not working.
On Thu, Mar 29, 2001 at 05:31:39PM +0100, Martin E. Koss wrote: > I just pasted: > ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' NULL > into the 'Run SQL' box on phpMyAdmin and it did exactly what it should do. I > did it both online (hosting servers) and offline on my Win/Apache and both > are fine, new column added. > > However, via the PHP script we're discussing it doesn't create the column or > generate an error. The username and password that phpMyAdmin uses is the > same as the one the connections for the web site uses and that includes full > privelidges. There is still one thing I want to be clear on. Are your php script and phpMyAdmin running on the same server? With mysql you can give privileges to a user on a specific server, so user foo on server bar could have different privileges than user foo on server bar2. This is the only thing that I can think of that might be happening. -- Jason Stechschulte [EMAIL PROTECTED] -- But you have to allow a little for the desire to evangelize when you think you have good news. -- Larry Wall in <[EMAIL PROTECTED]> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] ALTER TABLE - code not working.
Hello, "Martin E. Koss" wrote: > > While I appreciate your comments about metabase I simply don't have time to > start the project again, it has taken a long time to get this far. Perhaps > I'll look at metabase for future developments. > > In the meantime, anyone seeing this message for the first time, I'm still > struggling with my code below: Your mistake is very basic. If you read my message again, you can see that I am telling you that you are forgetting to declare the type of the column that you want to add. My suggestion to use Metabase is that it helps you to maintain database schemas without having to struggle with the way that the database wants you to declare the changes you want to be done. If you are having difficulty to understand how it needs to be done now, chances are that you will still have difficulty to figure how to make these and other types of database schema changes in the future. If switching to Metabase would be a good idea to avoid your difficulties, it is up to you to figure. Manuel Lemos > > Martin. > > -Original Message- > From: Manuel Lemos [mailto:[EMAIL PROTECTED]] > Sent: 29 March 2001 14:05 > To: [EMAIL PROTECTED]; Martin E. Koss > Subject: Re: [PHP-DB] ALTER TABLE - code not working. > > Hello, > > "Martin E. Koss" wrote: > > > > 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","myusername","mypassword"); > 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. > > I presume that the $Prod_Code is just the name of the field. > YES! You assume right. > Martin. > > You also > need to declare the type of the field. BTW, if you declare the default > value too in the ALTER TABLE statement the existing rows will be filled > with that value in that column. > > You may want to look at Metabase which is a PHP database abstraction > package that is able to install and maintain database schema giving just > a schema description file defined in a specific XML format. Metabase is > able to parse the schema definitions and install any tables, fields, > indexes and sequences described in the schema definition. > > When you want to change anything in your schema (adding, removing, > altering tables, fields, indexes and sequences) Metabase manager will > figure the changes you made in the schema definition and apply them to > the installed database without disturbing any data already inserted > after the first time the schema was installed or it was changed for the > last time. No sweat, no risk mistake. Look at Metabase here: > > http://phpclasses.UpperDesign.com/browse.html/package/20 > > Manuel Lemos > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
I just pasted: ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' NULL into the 'Run SQL' box on phpMyAdmin and it did exactly what it should do. I did it both online (hosting servers) and offline on my Win/Apache and both are fine, new column added. However, via the PHP script we're discussing it doesn't create the column or generate an error. The username and password that phpMyAdmin uses is the same as the one the connections for the web site uses and that includes full privelidges. Baffled - me too! Martin -Original Message- From: Jason Stechschulte [mailto:[EMAIL PROTECTED]] Sent: 29 March 2001 16:54 To: Martin E. Koss Cc: Jason Stechschulte; [EMAIL PROTECTED] Subject: Re: [PHP-DB] ALTER TABLE - code not working. On Thu, Mar 29, 2001 at 03:53:07PM +0100, Martin E. Koss wrote: > I did what you suggested and (exactly as it appears in the browser window) > here is what is sent to the screen: > > ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' > > The new item (sent from the previous form) is added to the database but the > new column is NOT added to the other table, but no error is displayed. Ok, this is a new one for me. I've never seen mysql_error() not return an error *and* the sql statement not work. You mentioned earlier that you are able to do this using phpMyAdmin, is that on the same server that you are running your php script from? I am beginning to wonder if this isn't a permissions problem. Does the user you are using have the correct privileges from the server your php script runs on? -- Jason Stechschulte [EMAIL PROTECTED] -- break; /* don't do magic till later */ -- Larry Wall in stab.c from the perl source code -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] ALTER TABLE - code not working.
On Thu, Mar 29, 2001 at 03:53:07PM +0100, Martin E. Koss wrote: > I did what you suggested and (exactly as it appears in the browser window) > here is what is sent to the screen: > > ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' > > The new item (sent from the previous form) is added to the database but the > new column is NOT added to the other table, but no error is displayed. Ok, this is a new one for me. I've never seen mysql_error() not return an error *and* the sql statement not work. You mentioned earlier that you are able to do this using phpMyAdmin, is that on the same server that you are running your php script from? I am beginning to wonder if this isn't a permissions problem. Does the user you are using have the correct privileges from the server your php script runs on? -- Jason Stechschulte [EMAIL PROTECTED] -- break; /* don't do magic till later */ -- Larry Wall in stab.c from the perl source code -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
Apparently there is nothing obviously wrong with the SQL. No-one else has said that it is wrong. In fact a couple have said that it looks ok. One thing is that if I echo $result to the screen I get nothing! Martin. -Original Message- From: Walter Franssen [mailto:[EMAIL PROTECTED]] Sent: 29 March 2001 15:57 To: Jason Stechschulte Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] ALTER TABLE - code not working. Is the SQL statment correct. Don't is must be ALTER TABLE vips ADD COLUMN $NewCol VARCHAR(50) NULL"; -Original Message- From: Jason Stechschulte [mailto:[EMAIL PROTECTED]] Sent: donderdag 29 maart 2001 16:29 To: Martin E. Koss Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] ALTER TABLE - code not working. On Thu, Mar 29, 2001 at 12:20:41PM +0100, Martin E. Koss wrote: > 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. If you haven't gotten a fix for this yet, then try adding: echo "$AddColQuery\n".mysql_error($conID)."\n"; after your mysql_query() call. This allows you to see the exact sql you are executing, and you will get to see the error mysql is returning. This has helped me find something strange with what I was doing when I could have sworn there was nothing wrong with my code. -- Jason Stechschulte [EMAIL PROTECTED] -- As someone pointed out, you could have an attribute that says "optimize the heck out of this routine", and your definition of heck would be a parameter to the optimizer. -- Larry Wall in <[EMAIL PROTECTED]> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
Is the SQL statment correct. Don't is must be ALTER TABLE vips ADD COLUMN $NewCol VARCHAR(50) NULL"; -Original Message- From: Jason Stechschulte [mailto:[EMAIL PROTECTED]] Sent: donderdag 29 maart 2001 16:29 To: Martin E. Koss Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] ALTER TABLE - code not working. On Thu, Mar 29, 2001 at 12:20:41PM +0100, Martin E. Koss wrote: > 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. If you haven't gotten a fix for this yet, then try adding: echo "$AddColQuery\n".mysql_error($conID)."\n"; after your mysql_query() call. This allows you to see the exact sql you are executing, and you will get to see the error mysql is returning. This has helped me find something strange with what I was doing when I could have sworn there was nothing wrong with my code. -- Jason Stechschulte [EMAIL PROTECTED] -- As someone pointed out, you could have an attribute that says "optimize the heck out of this routine", and your definition of heck would be a parameter to the optimizer. -- Larry Wall in <[EMAIL PROTECTED]> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
I did what you suggested and (exactly as it appears in the browser window) here is what is sent to the screen: ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' The new item (sent from the previous form) is added to the database but the new column is NOT added to the other table, but no error is displayed. Martin. -Original Message- From: Jason Stechschulte [mailto:[EMAIL PROTECTED]] Sent: 29 March 2001 15:29 To: Martin E. Koss Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] ALTER TABLE - code not working. On Thu, Mar 29, 2001 at 12:20:41PM +0100, Martin E. Koss wrote: > 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. If you haven't gotten a fix for this yet, then try adding: echo "$AddColQuery\n".mysql_error($conID)."\n"; after your mysql_query() call. This allows you to see the exact sql you are executing, and you will get to see the error mysql is returning. This has helped me find something strange with what I was doing when I could have sworn there was nothing wrong with my code. -- Jason Stechschulte [EMAIL PROTECTED] -- As someone pointed out, you could have an attribute that says "optimize the heck out of this routine", and your definition of heck would be a parameter to the optimizer. -- Larry Wall in <[EMAIL PROTECTED]> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] ALTER TABLE - code not working.
On Thu, Mar 29, 2001 at 12:20:41PM +0100, Martin E. Koss wrote: > 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. If you haven't gotten a fix for this yet, then try adding: echo "$AddColQuery\n".mysql_error($conID)."\n"; after your mysql_query() call. This allows you to see the exact sql you are executing, and you will get to see the error mysql is returning. This has helped me find something strange with what I was doing when I could have sworn there was nothing wrong with my code. -- Jason Stechschulte [EMAIL PROTECTED] -- As someone pointed out, you could have an attribute that says "optimize the heck out of this routine", and your definition of heck would be a parameter to the optimizer. -- Larry Wall in <[EMAIL PROTECTED]> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
While I appreciate your comments about metabase I simply don't have time to start the project again, it has taken a long time to get this far. Perhaps I'll look at metabase for future developments. In the meantime, anyone seeing this message for the first time, I'm still struggling with my code below: Martin. -Original Message- From: Manuel Lemos [mailto:[EMAIL PROTECTED]] Sent: 29 March 2001 14:05 To: [EMAIL PROTECTED]; Martin E. Koss Subject: Re: [PHP-DB] ALTER TABLE - code not working. Hello, "Martin E. Koss" wrote: > > 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","myusername","mypassword"); 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. I presume that the $Prod_Code is just the name of the field. YES! You assume right. Martin. You also need to declare the type of the field. BTW, if you declare the default value too in the ALTER TABLE statement the existing rows will be filled with that value in that column. You may want to look at Metabase which is a PHP database abstraction package that is able to install and maintain database schema giving just a schema description file defined in a specific XML format. Metabase is able to parse the schema definitions and install any tables, fields, indexes and sequences described in the schema definition. When you want to change anything in your schema (adding, removing, altering tables, fields, indexes and sequences) Metabase manager will figure the changes you made in the schema definition and apply them to the installed database without disturbing any data already inserted after the first time the schema was installed or it was changed for the last time. No sweat, no risk mistake. Look at Metabase here: http://phpclasses.UpperDesign.com/browse.html/package/20 Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] ALTER TABLE - code not working.
Hello, "Martin E. Koss" wrote: > > 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. I presume that the $Prod_Code is just the name of the field. You also need to declare the type of the field. BTW, if you declare the default value too in the ALTER TABLE statement the existing rows will be filled with that value in that column. You may want to look at Metabase which is a PHP database abstraction package that is able to install and maintain database schema giving just a schema description file defined in a specific XML format. Metabase is able to parse the schema definitions and install any tables, fields, indexes and sequences described in the schema definition. When you want to change anything in your schema (adding, removing, altering tables, fields, indexes and sequences) Metabase manager will figure the changes you made in the schema definition and apply them to the installed database without disturbing any data already inserted after the first time the schema was installed or it was changed for the last time. No sweat, no risk mistake. Look at Metabase here: http://phpclasses.UpperDesign.com/browse.html/package/20 Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] ALTER TABLE - code not working.
yes, I have full access rights. Using the same user and password (for example) as I use when using phpMyAdmin and have no problems altering tables with that. Martin. -Original Message- From: IceCold [mailto:[EMAIL PROTECTED]] Sent: 29 March 2001 13:18 To: Martin E. Koss Subject: RE: [PHP-DB] ALTER TABLE - code not working. Sorry but are you sure to have enought grant privilege to alter table? Cordiali Saluti. Matteo Indorato Cometa Comunicazioni S.r.L www.davide.it Filtered Access to the NET Obtain your account for free TODAY!! -Original Message- From: Martin E. Koss [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 29, 2001 1:21 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] ALTER TABLE - code not working. 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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] ALTER TABLE - code not working.
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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]