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
[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]

Reply via email to