Hi,

Tuesday, December 9, 2003, 4:58:30 PM, you wrote:


ijc> Hi all, 
ijc>  I am trying to do a simple INSERT data into the database using the following
ijc> php script but the problem here is that whenever I click "submit", the script
ijc> only insert a "NULL" value into the columns into the datadase instead the 
ijc> value I enter in the forms field....SELECT query was successful but not 
ijc> INSERT..

ijc> A snip of the code are as follow:

ijc> <?php
ijc> //declare error variable
ijc> $err = "";

ijc> //set error variable
ijc> $err .= check_tutor_name();
ijc> $err .= check_tutor_contact();
ijc> $err .= check_tutor_email();
ijc> $err .= check_tutor_profile();

ijc> //define connection string
ijc> $dsn = "mysql://root:[EMAIL PROTECTED]/table1";

ijc> //connect to DB
ijc> $db = DB::connect ($dsn);
ijc> //check for any DB connection errors
ijc>    if (DB::isError ($db))
ijc>        die ($db->getMessage());

$tutor_name = $db->>quote($POST["tutor_name"]);
ijc> $tutor_contact = $db->quote($POST["tutor_contact"]);
$tutor_email = $db->>quote($POST["tutor_email"]);
ijc> $tutor_profile = $db->quote($POST["tutor_profile"]);


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


ijc> //execute query statement
$result = $db->>query($sql);//check for DB query error
ijc> if( DB::isError($result) ) {
ijc>     die ($result->getMessage());<?php if( $_POST["submit"] != "Save" )
ijc> {
?>>



ijc> **************************HTML**************************************

ijc> <div align="center">
ijc> <form name="classinfo" action="<?php echo $_SERVER["PHP_SELF"]; ?>"  
method="post">>
ijc> <input type="hidden" name=form_submitted" value="1">

ijc> <table name="add_tutor"  border=0px cellpadding="0" cellspacing="2" 
width="900">>
ijc> <tr>
ijc> <th class="darkgreen" width="100%" colspan="2"><b>Teacher</b></th>
ijc> </tr>
ijc> <tr>
ijc>      <td class="lighter" width="200">Name:</td>
ijc>      <td class="lighter" width="500"><Input type="text" size="50" 
name="tutor_name">></td>
ijc>    </tr>
ijc> <tr>
ijc> <td class="darker" width="150">Contact No:</td>
ijc> <td class="darker" width="150"><Input type="text" size="30" 
ijc> name="tutor_contact"></td>
ijc>    </tr>
ijc> <tr>
ijc> <td class="lighter" width="150">Email:</td>
ijc>      <td class="lighter" width="150"><Input type="text" size="50" 
name="tutor_email">></td>
ijc>    </tr>

ijc> <tr>
ijc> <td class="darker" width="150">Profile:</td>
ijc>      <td class="darker" width="150"><TEXTAREA class="textarea" 
ijc> name="tutor_profile" ROWS=6 COLS=70>
ijc> </TEXTAREA>
ijc> </td>
ijc> </tr>
ijc> }


ijc> So, what could be the problem with the code I have wriiten???
ijc> Any help are appreciated.


ijc> Irin.


you need $_POST[] for the variables

-- 
regards,
Tom

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

Reply via email to