The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Create a Table with name from a form?

I have a form that a user enters a restaurant name into. The PHP code should create a MySQL table, using the posted value as the table name. I've spent hours looking over this, but I still keep getting an error, and the table does not get created. Thanks in advance.

-- ERROR -----------------------------

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource on line 37

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource on line 37
: 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 ''cars' (lineid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, item TEXT, descrip TEXT,' at line 1

As far as your PHP errors go, you are trying to pass your SQL query to mysql_errno and mysql_error, which is wrong. You call them with no parameters to get information on the last error, just as you are doing on the line not generating a PHP error:

It seems very odd to have a table for each user restaurant, why not create a table called Restaurants and just insert all the users restaurants in there, give them all a unique Id and you are sorted for anything you could possibly want to do.