Mikey
Mikey

Reputation: 396

Error when creating a relational database in phpMyAdmin

I am attempting to create a relational MySQL database in phpMyAdmin. The basic table structure is this:

productsTbl:

ID (primary key, int, 11), Name (varchar, 20), ColourID (int, 02)

coloursTbl:

ID (primary key, int 11), Colour (varchar, 20)

I am trying to create a relation on the design tab between the ID in the coloursTbl and the ColourID in the producsTbl but I get the following error:

{
    "exception": {
        "mode": "onerror",
        "message": "Uncaught TypeError: Cannot read property 'document' of undefined",
        "stack": [
            {
                "line": 16,
                "func": "PrintXML",
                "context": [
                    "{",
                    "    var $root = $(data).find('root');",
                    "    if ($root.length === 0) {",
                    "        // error",
                    "        var myWin = window.open('', 'Report', 'width=400, height=250, resiz//...",
                    "        var tmp = myWin.document;",
                    "        tmp.write(data);",
                    "        tmp.close();",
                    "    } else {",
                    "        // success",
                    "        if ($root.attr('act') == 'save_pos') {"
                ],
                "filename": "pmd/ajax.js"
            }
        ],
        "useragent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36",
        "uri": "pmd_general.php?target="
    },
    "script_name": "pmd_general.php",
    "pma_version": "4.1.12",
    "browser_name": "CHROME",
    "browser_version": "36.0.1985.125",
    "user_os": "Win",
    "server_software": "Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11",
    "user_agent_string": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36",
    "locale": "en",
    "configuration_storage": "enabled",
    "php_version": "5.5.11",
    "microhistory": {
        "pages": [
            {
                "hash": "tbl_change.php?db=test&table=colours&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "tbl_replace.php?db=test&table=colours&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "tbl_change.php?db=test&table=colours&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "tbl_replace.php?db=test&table=colours&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "sql.php?db=test&table=colours&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "db_structure.php?db=test&table=&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            },
            {
                "hash": "pmd_general.php?db=test&table=&server=1&target=&token=fdc2fa4ced95c29ba26a3e2d58afb9ef",
                "params": {
                    "opendb_url": "db_structure.php",
                    "safari_browser": "0",
                    "querywindow_height": "400",
                    "querywindow_width": "600",
                    "collation_connection": "utf8mb4_general_ci",
                    "lang": "en",
                    "server": "1",
                    "text_dir": "ltr",
                    "pma_text_default_tab": "Browse",
                    "pma_text_left_default_tab": "Structure",
                    "confirm": "true"
                }
            }
        ],
        "current_index": "7"
    }
}

What does this mean ??

Upvotes: 2

Views: 2038

Answers (1)

SystemX17
SystemX17

Reputation: 3715

I had the same problem and corrected it using the following steps:

1) Go to the products table

2) Go to the structure

3) On the column ColourID click Index

4) Go back and create the relationship

This will fix your problem

Upvotes: 3

Related Questions