I don't understand...I thought(could I be wrong?), this is how you create a table.
I did the "or die" too, but no error is returned. So I echo'd the results of
$sql=(yadayadayada) to the screen, so I could get a look at what exactly was going into the mysql_query(CREATE TABLE construct.

    Look at your code. This line is wrong....

    mysql_query(sql$, dbh$);
    

      Okay, I'm sorry, but I just started learning PHP 3 days ago, so maybe you could be a bit more specific. In fact, I just started learning any kind of web design a few weeks ago, and so far, this is my first problem. Please explain? How should it be?

        mysql_query($sql, $dbh) or die(mysql_error());
        

        Notice the $ is before the name of the variable, not after.

          Oh, okay, fixed it.....the dbh$, used to money, $5.00 is five dollars, so I say in in my head....dbh dollars, then it translates to dbh$. Let me try that real quick.

          That didn't do it. still no table....🙁

            The whole query was full of unnessary quotes this will work

            $sql = "CREATE TABLE $newname (
                      id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
                      title VARCHAR(30), 
                      metakeywords VARCHAR(50), 
                      metadescription VARCHAR(50), 
                      imgloc VARCHAR(256) NOT NULL, 
                      description VARCHAR(1000) 
                     )" ;
            $result = mysql_query($sql)//this was wrong
              or die("The Query failed. MySQL said".mysql_error());

              Okay, so I should put the query in a variable? Let me give that a try, thanks about the quotes, I copied that from the MySqlAdmin PhP maker, I got that cleaned up already.

                Okay, I figured it out. I was entering 2 names.....ie Boo Bah, into the query, table names can only be one word....Boo_Bah, thanks everyone...That worked...now my next problem.......How do I get PHP to insert a _ or %20 where the space is? Or should I do that by hand? If by hand, how do I trap it when someone accidentally enters a "space"?

                  Okay, I figured it out.

                  Brilliant, considering hundreds had failed before you. :-)

                  As for your other problem, you dont want to replace spaces with %20, that wont work either. Replace spaces with

                  $newname = str_replace(' ','_',$newname);
                  

                    Actually, it was me that failed, it wouldn't have been possible for someone to figure it out, because I never thought to mention that I was using 2 words in the table name. So, not brilliant, just persistant. Thankyou though. What I did to solve the other problem is to ask for the name in 2 fields, firstname, and last name. Then when the names were passed to PHP, i simply put them together like so
                    $wholename=$firstname."_".$lastname;

                      Um, table names can contain spaces if they're quoted in queries:

                       $sql = "CREATE TABLE `$newname` (
                                id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                                title VARCHAR(30),
                                metakeywords VARCHAR(50),
                                metadescription VARCHAR(50),
                                imgloc VARCHAR(256) NOT NULL,
                                description VARCHAR(1000)
                               )" ; 

                      (Caveat: I don't actually use MySQL, so I'm relying on the referenced manual page for this information. I do know you can have spaces in table names in e.g., PostgreSQL and SQL Server, and I presume MySQL's parser is just as smart.)

                        That may be true but

                        Table names cannot contain ‘/’, ‘\’, ‘.’, or characters that are not allowed in a filename.

                        . My server is a linux server, and linux doesn't allow spaces in file names. When windows comes across a space, it replaces the space with %20 for compatibility. Thanks for the link though, that had a load of good information.

                          Um, no; Windows leaves it as a space (just look at "C:\Program Files\").

                          And over on my Linux machine:

                          [weed@localhost weed]$ touch "a file with spaces in the name"
                          [weed@localhost weed]$ ls
                          00004121.jpg*                     Desktop/      gshhs.tgz    ogg/
                          a file with spaces in the name    Documents/    fonts.txt
                          [weed@localhost weed]$
                          

                          No probs.

                            Im sorry, I meant windows adds %20 when on the internet. If a webname has a space, it is filled with %20.

                              Okay. Lesson for today: http://www.w3.org/TR/chips/#uri

                              A common mistake, responsible for many HTTP implementations problems, is to think this is equivalent to a filename within a computer system. This is wrong. URIs have, conceptually, nothing to do with a file system. One should remember that at all times when dealing with the World Wide Web.

                                Write a Reply...