Hi, for the “insert into” part of the code, where i list the values, I’m getting a bunch of “undefined variable” notices. The thing that is weird to me though, is the fact that the first value “student ID” doesn’t bring up this notice, and yesterday (for some reason it doesn’t do this today, it just comes up with the ‘ERROR’) it would say that the studentID row had been updated.
[php]<?php
$studentID = isset($_POST[‘studentID’])?strip_tags($_POST[‘studentID’]):null;
$firstName = isset($_POST[‘fullName’])?strip_tags($_POST[‘fullName’]):null;
if(isset($_POST[‘position’]) )
{
$varposition = $_POST[‘position’];
$errorMessage = “”;
}
if(isset($_POST[‘experience’]));
if(empty($aexperience))
{
echo(“You did not check experience”);
}
else
{
$N = count($aexperience);
}
if(isset($_POST[‘willDemonstrate’]));
if(empty($awillDemonstrate))
{
echo(“You did not choose any modules to demonstrate”);
}
else
{
$N = count($awillDemonstrate);
}
if(isset($_POST[‘willNotDemonstrate’]));
if(empty($awillNotDemonstrate))
{
echo(“You did not choose any modules to not demonstrate”);
}
else
{
$N = count($awillNotDemonstrate);
}
$firstName = isset($_POST[‘maxHoursAvailable’])?strip_tags($_POST[‘maxHoursAvailable’]):null;
if(isset($_POST[‘trainingNeeded’]) )
{
$varposition = $_POST[‘trainingNeeded’];
$errorMessage = “”;
}
$db = new mysqli(‘localhost’, ‘root’, ‘’, ‘modules’);
if (mysqli_connect_errno()) {
echo ‘Error: Could not connect to database. Please try again later.’;
exit;
}
// Insert data into mysql
$query="INSERT INTO tutors (studentID, fullName, position, experience, willDemonstrate, willNotDemonstrate, maxHoursAvailable, trainingNeeded)
VALUES (’$studentID’, ‘$fullName’, ‘$position’, ‘$experience’, ‘$willDemonstrate’, ‘$willNotDemonstrate’, ‘$maxHoursAvailable’, ‘$trainingNeeded’) ";
if($result){
echo $db->affected_rows.“information has been updated.”;
} else {
echo “ERROR”;
}
//close mysql
$db->close();
?> [/php]
I know it’s kind of a mess right now and I could put all those issets into a loop probably but I would just like it to work before I make it neat!
If it’s relevant then ‘position’ and ‘trainingNeeded’ are ENUMS, and ‘experience’, ‘willDemonstrate’ and ‘willNotDemonstrate’ are sets.