Hi, Sorry I'm a complete beginner when it comes to MySQL... Anyway I'm trying to add something to a table that exists called 'dk_users' using PHPMySQL. The guide told me to add the following to this table: `petid` smallint(5) unsigned NOT NULL default '0', So to do that what do I do? After about 30 minutes of research my guess was that it's: ALTER TABLE 'dk_users' ADD `petid` smallint(5) unsigned NOT NULL default '0'; Is that right? Because whenever I do that in SQL in PHPMySQL is just gives me the error: #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''dk_users' ADD `petid` smallint(5) unsigned NOT NULL default '0 I don't really know what other information people need but please tell me if you do require any more info. And also... thanks in advance
I ran into problems like this, where simple 'changes' were generating errors till I found the correct syntax for what I wanted to do. Over time I grew tired of this, like altering tables, and when with a GUI. I use MySQL CC http://freshmeat.net/projects/mysqlcc/ I found it very easy to use. Tip: Remember to allow access from your ip address to your mysql server via the CPanel/MySQL page. hth, tom
Thanks for the advice! I'll check it out... But if someone does no how to fix this problem please teach me!
$query = "ALTER TABLE dk_users ADD COLUMN petid int(5) UNSIGNED DEFAULT '0' NOT NULL"; mysql_query($query); PHP: If you want it in a particular place say after field "x", you can use NOT NULL AFTER fieldname_x