Professional Web Applications Themes

creating table - can't - PHP Development

I've read around, especially at mysql.com to see if there are any limitations to tablenames, one is 64 characters and the other one seems to be that a tablename can't exist only numeric. So, within PHP I try to create a table with name "12345-name" and it fails entirely. It get's me rather puzzled as it should be possible according to the mysql manual. Of course, the table definition follows as it should. If i change the tablename to only "name" .. then I can create the table under Mysql 4.0.11a. But I want my tablenames to consist of faxnumber-name, ...

  1. #1

    Default creating table - can't


    I've read around, especially at mysql.com to see if there are any
    limitations to tablenames, one is 64 characters and the other one seems to
    be that a tablename can't exist only numeric.

    So, within PHP I try to create a table with name "12345-name" and it fails
    entirely.

    It get's me rather puzzled as it should be possible according to the mysql
    manual.
    Of course, the table definition follows as it should. If i change the
    tablename to only "name" .. then I can create the table under Mysql
    4.0.11a.
    But I want my tablenames to consist of faxnumber-name, nothing else.

    Is there anything I missed somewhere that prevents me from doing what I
    want?

    I'm sorta confused here ...

    /Andreas

    --
    Registeret Linux user #292411
    Andreas Paasch Guest

  2. #2

    Default Re: creating table - can't

    Works fine for me... just tried it with phpMyAdmin... try not using quotes,
    or single quotes? Then again I do believe im on MySQL 3.X... maybe thats
    it?


    -Eric Kincl

    Andreas Paasch wrote:
    >
    > I've read around, especially at mysql.com to see if there are any
    > limitations to tablenames, one is 64 characters and the other one seems to
    > be that a tablename can't exist only numeric.
    >
    > So, within PHP I try to create a table with name "12345-name" and it fails
    > entirely.
    >
    > It get's me rather puzzled as it should be possible according to the mysql
    > manual.
    > Of course, the table definition follows as it should. If i change the
    > tablename to only "name" .. then I can create the table under Mysql
    > 4.0.11a.
    > But I want my tablenames to consist of faxnumber-name, nothing else.
    >
    > Is there anything I missed somewhere that prevents me from doing what I
    > want?
    >
    > I'm sorta confused here ...
    >
    > /Andreas
    >
    Eric Kincl Guest

  3. #3

    Default Re: creating table - can't

    On Mon, 10 Nov 2003 23:39:34 +0100, Andreas Paasch <AndreasPaasch.Net> wrote:
    >I've read around, especially at mysql.com to see if there are any
    >limitations to tablenames, one is 64 characters and the other one seems to
    >be that a tablename can't exist only numeric.
    >
    >So, within PHP I try to create a table with name "12345-name" and it fails
    >entirely.
    Post error messages and example code.

    To create a table with a bad name like that requires quotes around the name.
    The type of quotes depends on with what options the MySQL server was started.
    If you ever need to quote identifiers, it almost always means you chose a bad
    name for the identifier...
    >It get's me rather puzzled as it should be possible according to the mysql
    >manual.
    >Of course, the table definition follows as it should. If i change the
    >tablename to only "name" .. then I can create the table under Mysql
    >4.0.11a.
    >But I want my tablenames to consist of faxnumber-name, nothing else.
    Why are you encoding data in the table name?

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  4. #4

    Default Re: creating table - can't

    Andy Hassall wrote:
    > On Mon, 10 Nov 2003 23:39:34 +0100, Andreas Paasch <AndreasPaasch.Net>
    > wrote:
    >
    [snip]
    >
    > Post error messages and example code.
    Sorry, I decided not to post those as I didn't think they were of value as I
    know the problem lies in the naming structure of the table to create ..
    just showing it here anyways, just in case ....

    Code part:
    $query = "CREATE TABLE '$folder'
    ... then follows the table definition ...
    in this instance is exactly $folder = "38747117-robertos"

    [errormsg]
    right syntax to use near ''38747117-robertos'
    [/errormsg]

    As mentioned, if I replace '$folder' with petersen, the table is created
    perfectly, so it's gotta be the name of the table.


    >
    > To create a table with a bad name like that requires quotes around the
    > name.
    > The type of quotes depends on with what options the MySQL server was
    > started. If you ever need to quote identifiers, it almost always means you
    > chose a bad name for the identifier...
    >
    [snip]

    It's actually not data, it's a faxnumber to distinguish several conflicting
    names. No workaround for the name ...



    --
    Registeret Linux user #292411
    Andreas Paasch Guest

  5. #5

    Default Re: creating table - can't

    Semicolon?? Can't forget those little POSes now, can we?


    -Eric Kincl

    Andreas Paasch wrote:
    > Andy Hassall wrote:
    >
    >> On Mon, 10 Nov 2003 23:39:34 +0100, Andreas Paasch <AndreasPaasch.Net>
    >> wrote:
    >>
    > [snip]
    >>
    >> Post error messages and example code.
    >
    > Sorry, I decided not to post those as I didn't think they were of value as
    > I know the problem lies in the naming structure of the table to create ..
    > just showing it here anyways, just in case ....
    >
    > Code part:
    >
    > $query = "CREATE TABLE '$folder'
    > ... then follows the table definition ...
    >
    >
    > in this instance is exactly $folder = "38747117-robertos"
    >
    > [errormsg]
    > right syntax to use near ''38747117-robertos'
    > [/errormsg]
    >
    > As mentioned, if I replace '$folder' with petersen, the table is created
    > perfectly, so it's gotta be the name of the table.
    >
    >
    >
    >>
    >> To create a table with a bad name like that requires quotes around the
    >> name.
    >> The type of quotes depends on with what options the MySQL server was
    >> started. If you ever need to quote identifiers, it almost always means
    >> you chose a bad name for the identifier...
    >>
    > [snip]
    >
    > It's actually not data, it's a faxnumber to distinguish several
    > conflicting names. No workaround for the name ...
    >
    >
    >
    Eric Kincl Guest

  6. #6

    Default Re: creating table - can't

    On Tue, 11 Nov 2003 00:02:09 +0100, Andreas Paasch <AndreasPaasch.Net> wrote:
    >Andy Hassall wrote:
    >
    >> On Mon, 10 Nov 2003 23:39:34 +0100, Andreas Paasch <AndreasPaasch.Net>
    >> wrote:
    >>
    >[snip]
    >>
    >> Post error messages and example code.
    >
    >Sorry, I decided not to post those as I didn't think they were of value as I
    >know the problem lies in the naming structure of the table to create ..
    >just showing it here anyways, just in case ....
    >
    >Code part:
    >
    > $query = "CREATE TABLE '$folder'
    > ... then follows the table definition ...
    >
    Single quotes '' are for string literals, not identifiers.

    In ANSI mode, quoted identifiers are surrounded by double quotes "" (as in
    many other databases).

    MySQL tends to use backticks `` though.

    See the manual.
    [url]http://www.mysql.com/doentation/mysql/bychapter/manual_Reference.html#Legal_names[/url]
    >in this instance is exactly $folder = "38747117-robertos"
    >
    >[errormsg]
    > right syntax to use near ''38747117-robertos'
    >[/errormsg]
    Doesn't look like a MySQL 3.x error, what version are you running? You're also
    missing the start of the error message.
    >It's actually not data, it's a faxnumber to distinguish several conflicting
    >names. No workaround for the name ...
    You could always put the number at the end and drop the '-' so it's a normal
    name, e.g. robertos38747117.

    Looks like 'robertos' is a case of encoding data in a name too, then?

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  7. #7

    Default Re: creating table - can't

    Andy Hassall wrote:
    > On Tue, 11 Nov 2003 00:02:09 +0100, Andreas Paasch <AndreasPaasch.Net>
    > wrote:
    >
    [snip]

    > Single quotes '' are for string literals, not identifiers.
    >
    > In ANSI mode, quoted identifiers are surrounded by double quotes "" (as
    > in
    > many other databases).
    >
    > MySQL tends to use backticks `` though.
    >
    > See the manual.
    >
    [url]http://www.mysql.com/doentation/mysql/bychapter/manual_Reference.html#Legal_names[/url]
    >
    The backtic did the trick ... first time I realized that a single quote
    isn't a single quote, it's actually a backtick.

    Thanks a lot.

    /Andreas

    --
    Registeret Linux user #292411
    Andreas Paasch Guest

  8. #8

    Default Re: creating table - can't

    Andreas Paasch wrote:
    > So, within PHP I try to create a table with name "12345-name" and it fails
    > entirely.
    Can I assume you are creating tables at runtime?
    Unless you are explicityly doing this to handle bulk ware-house type
    stuff, then you'r probably going about things the wrong way. You should
    be able to scale your data without need to add entities (ie. modify your
    data structure).

    What is it that you are really trying to do?


    Terence Guest

  9. #9

    Default Re: creating table - can't

    Terence wrote:
    > Andreas Paasch wrote:
    >
    >> So, within PHP I try to create a table with name "12345-name" and it
    >> fails entirely.
    >
    > Can I assume you are creating tables at runtime?
    > Unless you are explicityly doing this to handle bulk ware-house type
    > stuff, then you'r probably going about things the wrong way. You should
    > be able to scale your data without need to add entities (ie. modify your
    > data structure).
    >
    > What is it that you are really trying to do?

    What I'm really trying to do is write some administrative pages that handle
    my import and selection of data based on a cvs-file.

    As I assume to get more and more customer into my system, it's a lot easier
    to automate the procedure.
    So I create a customer and import that customers cvs-file according to a
    very special structure which is written into the cvs-filename.
    That file name in turn is split and creates then the folder structure for
    easy access later on and in order to keep consensus.

    I doubt I go about it the wrong way, just lack some in-depth understanding
    ....

    /Andreas

    --
    Registeret Linux user #292411
    Andreas Paasch Guest

  10. #10

    Default Re: creating table - can't

    On Tue, 11 Nov 2003 10:44:55 +0100, Andreas Paasch
    <AndreasPaasch.Net> wrote:
    >What I'm really trying to do is write some administrative pages that handle
    >my import and selection of data based on a cvs-file.
    >
    >As I assume to get more and more customer into my system, it's a lot easier
    >to automate the procedure.
    >So I create a customer and import that customers cvs-file according to a
    >very special structure which is written into the cvs-filename.
    >That file name in turn is split and creates then the folder structure for
    >easy access later on and in order to keep consensus.
    I think you're equating database tables to filesystem folders. A
    relational database isn't a filesystem. If you are creating customers,
    you should have a single `customer` entity (table).

    This table would have fields such as customer id, name, etc.

    As you create customers, add records to this table.

    Your database design should reflect the logical view of the data, as
    opposed to how it is physically stored.

    --
    David ( priz.co.uk )
    The Internet Prisoner Database: [url]http://www.priz.co.uk/ipdb/[/url]
    The Tarbrax Chronicle: [url]http://www.tarbraxchronicle.com/[/url]
    David Mackenzie Guest

  11. #11

    Default Re: creating table - can't

    Andreas Paasch wrote:
    > Terence wrote:
    >
    >
    >>Andreas Paasch wrote:
    >>
    >>
    >>>So, within PHP I try to create a table with name "12345-name" and it
    >>>fails entirely.
    >>
    >>Can I assume you are creating tables at runtime?
    >>Unless you are explicityly doing this to handle bulk ware-house type
    >>stuff, then you'r probably going about things the wrong way. You should
    >>be able to scale your data without need to add entities (ie. modify your
    >>data structure).
    >>
    >>What is it that you are really trying to do?
    >
    >
    >
    > What I'm really trying to do is write some administrative pages that handle
    > my import and selection of data based on a cvs-file.
    >
    > As I assume to get more and more customer into my system, it's a lot easier
    > to automate the procedure.
    > So I create a customer and import that customers cvs-file according to a
    > very special structure which is written into the cvs-filename.
    > That file name in turn is split and creates then the folder structure for
    > easy access later on and in order to keep consensus.
    >
    > I doubt I go about it the wrong way, just lack some in-depth understanding
    > ...
    >
    > /Andreas
    >
    You don't want a relational database system, you want a native XML
    database system.

    [url]http://xml.apache.org/xindice/[/url]
    or
    [url]http://exist.sourceforge.net/[/url]

    There are commercial ones if you need hardcore scalability. Tamino is
    the best one I've seen -- it's not cheap.


    Terence Guest

Similar Threads

  1. creating dynamic table in oracle
    By kishoreb in forum Coldfusion Database Access
    Replies: 1
    Last Post: May 10th, 06:12 PM
  2. creating a dynamic table with subcategories
    By davellaman in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 11th, 06:24 PM
  3. Creating a table or something like that
    By Strudel67 in forum Macromedia Director Basics
    Replies: 2
    Last Post: April 13th, 01:03 AM
  4. dynamically creating table
    By Rick Walsh in forum ASP.NET General
    Replies: 1
    Last Post: July 11th, 02:02 PM
  5. creating on-the-fly asp:table in the code file
    By Murtix Van Basten in forum ASP.NET General
    Replies: 2
    Last Post: June 25th, 07:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139