Re: problem with INSERT query
| From: | Viraj Kalinga Abayarathna | Date: | Tue, 09 Dec 2003 07:03:37 +0000 |
| Subject: | Re: problem with INSERT query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172235@lists.php.net to get a copy of this message | ||
insert following...
echo $sql;
immediatly after the folowing code block..
$sql = "INSERT INTO tutor (tutor_name, tutor_contact,tutor_email,tutor_profile)
VALUES ('$tutor_name', '$tutor_contact', '$tutor_email', '$tutor_profile')";
then execute the script, and check whether it show s the correct values for the
'$tutor_name', '$tutor_contact', '$tutor_email', '$tutor_profile'.
you will note the problem.
Viraj
irinchiang@justeducation.com wrote:
Hi all, I am trying to do a simple INSERT data into the database using the following php script but the problem here is that whenever I click "submit", the script only insert a "NULL" value into the columns into the datadase instead the value I enter in the forms field....SELECT query was successful but not INSERT.. A snip of the code are as follow: <?php //declare error variable $err = ""; //set error variable $err .= check_tutor_name(); $err .= check_tutor_contact(); $err .= check_tutor_email(); $err .= check_tutor_profile(); //define connection string $dsn = "mysql://root:********@localhost/table1"; //connect to DB $db = DB::connect ($dsn); //check for any DB connection errors if (DB::isError ($db))die ($db->getMessage());$tutor_name = $db->quote($POST["tutor_name"]); $tutor_contact = $db->quote($POST["tutor_contact"]); $tutor_email = $db->quote($POST["tutor_email"]); $tutor_profile = $db->quote($POST["tutor_profile"]); $sql = "INSERT INTO tutor (tutor_name, tutor_contact,tutor_email,tutor_profile)VALUES ('$tutor_name', '$tutor_contact', '$tutor_email', '$tutor_profile')";//execute query statement $result = $db->query($sql);//check for DB query error if( DB::isError($result) ) { die ($result->getMessage());<?php if( $_POST["submit"] != "Save" ) { ?> **************************HTML************************************** <div align="center"> <form name="classinfo" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <input type="hidden" name=form_submitted" value="1"> <table name="add_tutor" border=0px cellpadding="0" cellspacing="2" width="900"> <tr> <th class="darkgreen" width="100%" colspan="2"><b>Teacher</b></th> </tr> <tr><td class="lighter" width="200">Name:</td> <td class="lighter" width="500"><Input type="text" size="50" name="tutor_name"></td></tr> <tr> <td class="darker" width="150">Contact No:</td> <td class="darker" width="150"><Input type="text" size="30" name="tutor_contact"></td> </tr> <tr> <td class="lighter" width="150">Email:</td><td class="lighter" width="150"><Input type="text" size="50" name="tutor_email"></td></tr> <tr> <td class="darker" width="150">Profile:</td><td class="darker" width="150"><TEXTAREA class="textarea" name="tutor_profile" ROWS=6 COLS=70></TEXTAREA> </td> </tr> } So, what could be the problem with the code I have wriiten??? Any help are appreciated. Irin.