Re: [PHP] Alter Table newbie help needed ...
- Date: Sun, 20 Apr 2008 13:08:11 -0500
- From: "David Giragosian" <dgiragosian@xxxxxxxxx>
- Subject: Re: [PHP] Alter Table newbie help needed ...
On 4/20/08, revDAVE <Cool@xxxxxxxxxxxxxxxx> wrote:
>
> On 4/19/2008 2:37 PM, "Jason Norwood-Young" <jason@xxxxxxxxxxxxxxxxxxx>
> wrote:
>
> > Might be obvious but you are doing "mysql_query($sql);", right?
>
> Hello Jason,
>
> Thanks - Your idea worked well - for a while - but then I ran into
> trouble...
>
> I added : mysql_error() and it said:
>
>
> Table 'connect2.ztest' doesn't exist
>
> - so I guess it was not knowing to use the 'try1' connection ( try1.ztest)
> -
> (connect2 was some other one I set up for something else)
>
> I'm using Dreamweaver cs3 - maybe it's confused?
>
> Q: Is there a way to insure that it uses the right connection ( try1 - not
> connect2 )?
>
>
> BTW: I tried `try1.ztest` but it didn't like that:
>
> $sql = 'ALTER TABLE `try1.ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';
Is try1 the name of a database? The SQL syntax is
databasename.tablename.fieldname.
When you issue a query using mysql_query() you can explicitly indicate the
connection (returned by mysql_connect()) to use as the second parameter,
e.g., mysql_query($sql_Statement, $returnedConnectionObject);
HTH,
David