The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> create a table with $name
xxkasperxx
post Apr 11 2012, 10:06 PM
Post #1


Serious Coder
*****

Group: Members
Posts: 261
Joined: 30-April 11
Member No.: 14,449



I am trying to create a new table using a form like this
CODE

<form action='' method="POST">
            Name: <textarea rows="1" name="name" class="style"> </textarea><br>
            Percent: <textarea name="name" class="style">0%</textarea>
            <br>
            <input type="submit" name="add" value="ADD New User">
            </form>


and my php:

CODE

$name = $_POST['name'];
    if ($_POST)
    {
        mysql_query("CREATE TABLE '$name'(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30),
age INT)")
or die(mysql_error());  
    }


but i get this error
"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 ''0%'( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), ' at line 1"

How do i fix that?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
xxkasperxx
post Apr 12 2012, 08:11 PM
Post #2


Serious Coder
*****

Group: Members
Posts: 261
Joined: 30-April 11
Member No.: 14,449



Thank you for the quick reply!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 10:55 AM