I did what you suggested and (exactly as it appears in the browser window)
here is what is sent to the screen:


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.


-----Original Message-----
From: Jason Stechschulte [mailto:[EMAIL PROTECTED]]
Sent: 29 March 2001 15:29
To: Martin E. Koss
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
> 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
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