Re: Alter Table newbie help needed ...
| From: | Jason Norwood-Young | Date: | Sat, 19 Apr 2008 21:37:45 +0000 |
| Subject: | Re: Alter Table newbie help needed ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273308@lists.php.net to get a copy of this message | ||
On Sat, 2008-04-19 at 14:23 -0700, revDAVE wrote:
> Newbie - MAC - MAMP on port 8889
>
> I have this connection to Mysql database called 'test'
>
>
> Other Php stuff works ok but now I'm trying to alter the table (never did
> that before...)
>
>
>
> Connection called 'try1'...
>
> <?php
> # FileName="Connection_php_mysql.htm"
> # Type="MYSQL"
> # HTTP="true"
> $hostname_try1 = "127.0.0.1:8889";
> $database_try1 = "test";
> $username_try1 = "test";
> $password_try1 = "test";
> $try1 = mysql_pconnect($hostname_try1, $username_try1, $password_try1) or
> trigger_error(mysql_error(),E_USER_ERROR);
> ?>
>
> The lines below don't error but also don't do anything....
>
> I must be missing something here.... Right? Maybe it doesn't know to use
> try1 connection? How do I add that?
>
> <?php
> $sql = 'ALTER TABLE
ztest ADD
> myfield2 VARCHAR(10) NOT NULL;';
> ---or---
> $sql = 'ALTER TABLE ztest RENAME TO
> ztest2;';
>
> ?>
Might be obvious but you are doing "mysql_query($sql);", right?
Also add a try catch around your mysql_query to check what's happening.