----- Original Message -----
From: Pyran Firebrand <[EMAIL PROTECTED]>
Sent: Tuesday, August 28, 2001 2:32 PM
Subject: [PHP-DB] PHP/mySQL and INSERT statements

> Hello...
> I'm trying to enter a fair amount of text into a mySQL database from
> textfiles using PHP.  I'm having some problems, and I hope someone can
> me.  The table looks like this:
> Name    : rants
> id      : int auto_increment
> date    : varchar(8)
> category: char(1)
> title   : varchar(75)
> rtext   : text


>    // Write out everything that we have.
>    echo "Date: $date<br>\nTitle: $title<br>\nType:
> $type<br>\nText:<br>\n$text";
>    $query = "INSERT INTO rants VALUES (1, '$date', '$type', '$title',
> '$text')";
>    mysql_db_query($query, $db_link) or die ("<br>Problem!");
> }


> When I try to execute this, it doesn't add anything into the database, and
> prints out "Problem!".  I have absolutely no idea why.  Can someone give
> some direction here?  I would be eternally grateful for it.

Try this:

  $query = "INSERT INTO rants VALUES (NULL, '$date', '$type', '$title',

You shouldn't specify a value for a field if it is auto-increment.

Jason Wong
Gremlins Associates

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to