PHP/SQL - inserting into database null results

From: Date: Wed, 21 Aug 2002 13:25:30 +0000
Subject: PHP/SQL - inserting into database null results
Groups: php.general 
Request: Send a blank email to php-general+get-113451@lists.php.net to get a copy of this message
I am a new person to PHP. I have purchased and read PHP fast & easy by Julie Meloni and have also read the 24 hours PHP book. I am able to connect to the SQL database and insert into the database via my html form. However, the values are null. When I look at the data in my database, it reads " ", " ", " ", etc. I have tried a couple different code: $query = "INSERT INTO MemberReviews VALUES (' ','$memb_name', '$bookname','$author', '$grade', '$review') "; mysql_query($query); mysql_close(); or in the form itself, I have tried: <? # this is processed when the form is submitted # back on to this page (POST METHOD) if ($REQUEST_METHOD=="POST") { # double-up apostrophes $review = str_replace("'","''",$review); $author = str_replace("'","''",$author); # setup SQL statement $SQL = " INSERT INTO MemberReviews "; $SQL = $SQL . " (memb_name, bookname, author, grade, review) VALUES "; $SQL = $SQL . " ('$memb_name', '$bookname','$author', '$grade', '$review') "; #execute SQL statement $result = mysql_db_query($db,"$SQL",$cid); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><B>New Record Added</B></P>\n"); } ?> Thanks in advance for your help Jennifer

« previous php.general (#113451) next »