嗨,我不知道我的代码是什么错误我试图创建一个数据库和三个简单的表使用PHP和MySQL

时间:2018-04-15 00:28:14

标签: php mysql

<?php
    ## Hi I don't know whats wrong with my code im trying to create a  
       database and three simple tables using php and mySQL, I try to
       run it on a page on my local server and its giving this error 
       for when im trying to end the php code(?>, have no clue why
       but stack decided to put it as a comment at the end)
       This is the error : Parse error: syntax error, unexpected end 
       of file in /opt/lampp/htdocs/Gymbud/DatabaseConnection.php on 
       line 58  ##
    $db_user = ‘root’;
    $db_pass = ‘root’;
    $db_name = ‘Gymbud’;
    $db_host = '192.168.64.2';

    $mysqli = new mysqli ($db_host, $db_user , $db_pass , $db_name);


    // This code essentially just checks if we’re connected to the database or not and if not it prints an error message to the screen and exits the application
    if ($mysqli -> connect_errno) {
        printf( "Connect Failed: %s\n" . $mysqli -> connect_error);
        exit();
    }


   //This code just creates a table for the object (Posts)
    $Post_table = 
            "CREATE TABLE IF NOT EXISTS Gymbud (
                    ID bigint (20) UNSIGNED NOT NULL AUTO_INCREMENT,
                    Post_title text NOT NULL,
                    Post_content longtext NOT NULL,
                    Post_name varchar (20) NOT NULL,
                    Post_date date time NOT NULL,
                    PRIMARY KEY (ID)
                )” ;


            if ($mysqli->query($Post_table) === TRUE) {
                printf(“Post Table successfully created.\n”);
                } 

// 对不起,我必须提供更多详细信息,但我真的不知道还有什么可以说的,如果有人可以帮助我非常感激 //这段代码基本上只为上面的对象表创建一个元表

    $Post_meta_table = 
                “CREATE TABLE IF NOT EXISTS Post_meta (
                    Meta_ID bigint (20) UNSIGNED NOT NULL 
                    AUTO_INCREMENT,
                    Post_ID bigint (20) UNSIGNED NOT NULL,
                    Meta_key varchar (255),
                    Meta_value longtext,
                    PRIMARY KEY (Meta_ID)
                )”;


            if ($mysqli->query($Post_Meta_table) === TRUE) {
                printf(“Post Meta table successfully created.\n”);
                } 

               // This code essentially just creates a relationship 
                  table for the object table above 

    $Post_Tags_table = 
                “CREATE TABLE IF NOT EXISTS Post_Tag_Relationships (
                ID bigint (20) UNSIGNED NOT NULL AUTO_INCREMENT,
                Post_ID bigint (20) UNSIGNED  NOT NULL,
                Tag_ID bigint (20) UNSIGNED  NOT NULL,
                PRIMARY KEY (ID)
                )”;


            if ($mysqli->query($Post_Tags_table) === TRUE) {
                printf(“Post_Tags_Relationships table successfully  
                created.\n”);
            }

&GT;

对不起,我必须提供更多详细信息,但我真的不知道如果有人可以帮助我们,还有什么可以表达的。

0 个答案:

没有答案