SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need Help Creating Table using PHP with MYSQL====HELP

    Hello,
    I have being unable to Go forward since all these days about this issue.... Here is My code
    Code PHP:
    <body>
    <?php
    $sql = 'CREATE TABLE joke(
                              id INT NOT NULL AUTO_INCREMEMTT PRIMARY KEY,
                              joketext TEXT,
                              jokedate DATE NOT NULL
                              ) DEFAULT CHARACTER SET utf8';
    if (!mysqli_query($link, $sql));   my line 15
    {
        $output = 'Error creating joke table: ' . 
        mysqli_error($link);  my line 18
        include 'output.html.php';
        exit();
    }
    $output = 'Joke table sucessully Created.';
    include  'output.html.php';
     
    ?>
    </body>
    </html>
    And here is the Error I am Seeing... What is the Way Out

    "Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Createtable\index.php on line 15

    Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Createtable\index.php on line 18
    Error creating joke table:


    "I will really Appreciate If I can see a Solution.. thanks

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    You.. havent connected to a database, or the connection failed. You need to connect to a database (mysqli_connect) first.

  3. #3
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AUTO_INCREMEMTT should be AUTO_INCREMENT

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    That is also true, and will be the next error he gets. The error indicates though that the current problem is that $link does not exist yet.

    Also the database will probably demand a size on the id INT field


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
  •