Re: PHP/mySQL and INSERT statements

From: Date: Tue, 28 Aug 2001 07:26:55 +0000
Subject: Re: PHP/mySQL and INSERT statements
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11883@lists.php.net to get a copy of this message
----- Original Message ----- From: Pyran Firebrand <pyranf@hotmail.com> To: <php-db@lists.php.net> 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 help > me. The table looks like this: > > Name : rants > id : int auto_increment > date : varchar(8) > category: char(1) > title : varchar(75) > rtext : text [snip] > // 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!"); > } [snip] > 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 me > some direction here? I would be eternally grateful for it. Try this: $query = "INSERT INTO rants VALUES (NULL, '$date', '$type', '$title', '$text')"; You shouldn't specify a value for a field if it is auto-increment. hth -- Jason Wong Gremlins Associates www.gremlins.com.hk

« previous php.db (#11883) next »