RE: [PHP-DB] ALTER TABLE - code not working.

From: Date: Thu, 29 Mar 2001 15:13:31 +0000
Subject: RE: [PHP-DB] ALTER TABLE - code not working.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7993@lists.php.net to get a copy of this message
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:w.franssen@nexwork.nl] Sent: 29 March 2001 15:57 To: Jason Stechschulte Cc: php-db@lists.php.net 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:jpstech@unoh.edu] Sent: donderdag 29 maart 2001 16:29 To: Martin E. Koss Cc: php-db@lists.php.net 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<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> -- 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 -- 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

« previous php.db (#7993) next »