Re: ALTER TABLE - code not working.

From: Date: Thu, 29 Mar 2001 14:28:38 +0000
Subject: Re: ALTER TABLE - code not working.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7981@lists.php.net to get a copy of this message
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<br>\n".mysql_error($conID)."<br>\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 jpstech@unoh.edu -- 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 <199709081854.LAA20830@wall.org>

« previous php.db (#7981) next »