This is what I get after I "echo" my query statement:

INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile) 
VALUES ('NULL', 'NULL', 'NULL', 'NULL')

How come the value is null???

In my INSERT query, I already state my value variable to be the name of the 
fields in my html. Why is it still inserting "NULL" into the database when I 
have entered values in the HTML fields?????

 $sql = "INSERT INTO tutor (tutor_name, 
tutor_contact,tutor_email,tutor_profile) 
        VALUES   
       ('$tutor_name', '$tutor_contact', '$tutor_email', '$tutor_profile')";


What could be the problem??

Irin.
-------------------------------------------------------------------------------

Viraj Kalinga Abayarathna <[EMAIL PROTECTED]> wrote:

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 

-------------------------------------------------------------------------------

[EMAIL PROTECTED] 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:[EMAIL PROTECTED]/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> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to