Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31

    Unanswered: i cannot insert data , help!!!!

    i cannot insert data into my database , help!!
    this is my code

    <html>
    <head>
    <title>Add New MySQL User</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?php
    if(isset($_POST['add']))
    {
    //include 'library/config.php';
    //include 'library/opendb.php';
    $dbhost = 'localhost';
    $dbuser = 'administrator';
    $dbpass = '';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

    $dbname = 'test';

    mysql_select_db($dbname);
    $title = $_POST['title'];
    $description = $_POST['description'];
    $query = "INSERT INTO event (Event Title, Description ) VALUES ('$title', '$description')";
    mysql_query($query) or die('Error, insert query failed');

    $query = "FLUSH PRIVILEGES";
    mysql_query($query) or die('Error, insert query failed');

    include 'library/closedb.php';
    echo "New MySQL user added";
    }


    ?>

    <form method="post">
    <table width="400" border="0" cellspacing="1" cellpadding="2">
    <tr>
    <td width="100">Event Title</td>
    <td><input name="title" type="text" id="title"></td>
    </tr>
    <tr>
    <td width="100">Description</td>
    <td><input name="description" type="text" id="description"></td>
    </tr>
    <tr>
    <td width="100">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="100">&nbsp;</td>
    <td><input name="add" type="submit" id="add" value="Add New User"></td>
    </tr>
    </table>
    </form>

    </body>
    </html>

    can anyone help me with this ? when i insert data, it appear a error message 'Error, insert query failed'

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    22
    Quote Originally Posted by zw^
    $query = "INSERT INTO event (Event Title, Description ) VALUES ('$title', '$description')";
    try
    $query = "INSERT INTO event (`Event Title`, Description ) VALUES ('$title', '$description')";


    Erich

    Have a bit more sun in your heart

  3. #3
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    thanks for ur help

Posting Permissions

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