On Thu, 29 Mar 2001 21:18, 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 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.

Two things come to mind: echo your $AddColQuery to ensure you are getting 
what you hope you are getting :-) and use mysql_error() after you run 
mysql_query on your query, to see if there is an error message being 
returned.

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- 
PHP General 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]

Reply via email to