0

I wonder wether there is a limit for the maximum lengh of strings in arrays. I ve already checked my memory reserved for PHP (which is 128MB and therefore definitelly enough for my purposes) and am quite sure that i deteteced the actual problem:

My original array was:

$tabellenA = array
    (
        "userA" => array
            (
                "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
                "`name`" => "VARCHAR(20) NOT NULL",
                "`sirname`" => "VARCHAR(20) NOT NULL",
                "`userName`" => "VARCHAR( 50 ) NOT NULL",
                "`email`" => "VARCHAR(50) NOT NULL",            ,
                "`password`" => "VARCHAR(20) NOT NULL",
                "`country`" => "VARCHAR(150) NOT NULL",
                "`plz`" => "VARCHAR(50) NOT NULL",
                "`road`" => "VARCHAR(50) NOT NULL",
                "`city`" => "VARCHAR(50) NOT NULL",
                "`state`" => "VARCHAR(50) NOT NULL",
                "`house_number`" => "VARCHAR(50) NOT NULL",
                "`country`" => "VARCHAR(50) NOT NULL",
                "`timestamp`" => "DATETIME NOT NULL"


    )
);

and always called the Error Message: "Parse error: syntax error, unexpected ',', expecting ')' in C:\xampp\htdocs\Envifood\req\Constants.php on line 19" until i cut the array after line 18 so that the code looked like:

    $tabellenA = array
(
    "userA" => array
        (
            "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
            "`name`" => "VARCHAR(20) NOT NULL",
            "`sirname`" => "VARCHAR(20) NOT NULL",
            "`userName`" => "VARCHAR( 50 ) NOT NULL"/*,
            "`email`" => "VARCHAR(50) NOT NULL",            ,
            "`password`" => "VARCHAR(20) NOT NULL",
            "`country`" => "VARCHAR(150) NOT NULL",
            "`plz`" => "VARCHAR(50) NOT NULL",
            "`road`" => "VARCHAR(50) NOT NULL",
            "`city`" => "VARCHAR(50) NOT NULL",
            "`state`" => "VARCHAR(50) NOT NULL",
            "`house_number`" => "VARCHAR(50) NOT NULL",
            "`country`" => "VARCHAR(50) NOT NULL",
            "`timestamp`" => "DATETIME NOT NULL"*/
        )
);

Therefore I expected that there has to be some kind of maximum limit for strings in arrays but i did not find any but a hint that arrays (for reading big data files/xml to arrays) can get tremendously big... Additionally other arrays of mine have three times more entries and do work! Additionally I made a text Array with those keys but different, shorter contents, which do work.

Do you see my mistake or is it just that arrays do not work with larger strings?

nikma
  • 3
  • 4

3 Answers3

3

You have an excess , in your code at the line with email in it. That is causing the error. Removing that , will solve that error

Dacaspex
  • 669
  • 7
  • 15
1

The problem is not a limit, is a comma which shouldn't be in there.

$tabellenA = array
    (
        "userA" => array
            (
                "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
                "`name`" => "VARCHAR(20) NOT NULL",
                "`sirname`" => "VARCHAR(20) NOT NULL",
                "`userName`" => "VARCHAR( 50 ) NOT NULL",
                "`email`" => "VARCHAR(50) NOT NULL",         // , <--This little guy
                "`password`" => "VARCHAR(20) NOT NULL",
                "`country`" => "VARCHAR(150) NOT NULL",
                "`plz`" => "VARCHAR(50) NOT NULL",
                "`road`" => "VARCHAR(50) NOT NULL",
                "`city`" => "VARCHAR(50) NOT NULL",
                "`state`" => "VARCHAR(50) NOT NULL",
                "`house_number`" => "VARCHAR(50) NOT NULL",
                "`country`" => "VARCHAR(50) NOT NULL",
                "`timestamp`" => "DATETIME NOT NULL"


    )
);
Phiter
  • 14,570
  • 14
  • 50
  • 84
1

you have an extra comma (',') in email

sebastian
  • 31
  • 5