On Friday 12 December 2003 15:43, [EMAIL PROTECTED] wrote:
> I keep getting this error:
>
> Notice: Undefined index: tutor_id in /usr/local/..........
>
> What does "undefined index" exactly mean?? I did a search on the web but
> couldn't find any solutions.
Basically it means you're trying to access a non-existent item in the array.
> The line that cause this error is as follow:
>
> $tutor_id = $_POST["tutor_id"];
print_r($_POST)
will show all the items in $_POST. Is your form set to use the "post" method?
If not then look in $_GET for your form input data.
-------------------------------------------------------------------------------
yah my form has been set to use the POST method:
echo "<form name=\"edit_tutor\" method=\"post\" action=\"edit2.php\">";
What could be the problem???Or it could be related to "quoting" problem:
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");
or
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id=$tutor_id");
????
What is the right way to define the variable "$tutor_id" ????
--------------------------------------------------------------------------
For reference, I have copied the block of code below:
$dsn = "mysql://root:[EMAIL PROTECTED]/tablename";
//connect to DB
$db = DB::connect ($dsn);
//check for any DB connection errors
if (DB::isError ($db))
die ($db->getMessage());
$action = $_GET["action"];
$tutor_id = $_POST['tutor_id'];
print_r($_POST);
if($action == "delete")
{
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'");
$result = $db->query($sql);
if( DB::isError($result) ) {
die ($result->getMessage());
}
echo "<a href='../index/timetable_main.php'>Back to main</a>";
}
if($action == "edit")
{
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");
$row = mysql_fetch_array($sql);
echo "<form name=\"edit_tutor\" method=\"post\" action=\"edit2.php\">";
echo "Tutor ID : ".$row['tutor_id']."<br>";
echo "<input type=\"hidden\" name=\"tutor_id\" value=\"".$row
['tutor_id']."\">";
echo "Name : <input name=\"tutor_name\" type=\"text\" value=\"".$row
['tutor_name']."\"><br>";
echo "Contact No : <input type=\"text\" name=\"tutor_contact\" value=\"".$row
['tutor_contact']."\"><br>";
echo "E-mail : <input type=\"text\" name=\"tutor_email\" value=\"".$row
['tutor_email']."\"><br>";
echo "Profile : <input type=\"text\" name=\"tutor_profile\" value=\"".$row
['tutor_profile']."\"><br>";
echo "<input type=\"submit\" name=\"Submit\" value=\"Update\">";
echo "</form>";
}
?>
echo "The entry has been deleted <br><br>";
For reference, i have copied the block of code below:
Irin.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php