I can't get this mysql query to work properly. It completes with no errors but no information is inserted into the database. I'm not so concerned about finding an imediate solution but how can I get mysql to report what's going on behind the scenes?
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$tempProf = $_POST["professor"];
$tempProfArray = explode("=",$tempProf);
$prof = $tempProfArray[1];
$tempName = $_POST["name"];
$tempNameArray = explode("=",$tempName);
$name = $tempNameArray[1];
$tempNum = $_POST["number"];
$tempNumArray = explode("=",$tempNum);
$num = $tempNumArray[1];
$tempSec = $_POST["section"];
$tempSecArray = explode("=",$tempSec);
$section = $tempSecArray[1];
$tempCat = $_POST["category"];
$tempCatArray = explode("=",$tempCat);
$category = $tempCatArray[1];
$con=mysqli_connect("localhost","root","*****","******");
$result = mysqli_query($con,"SELECT * FROM professors where id='$prof'");
$row = mysqli_fetch_array($result);
if(empty($prof) || empty($name) || empty($num) || empty($section) || empty($category))
{
echo "emptyField";
}
elseif(!is_numeric($num) || !is_numeric($section))
{
echo "NaN";
}
elseif(empty($row))
{
mysqli_query($con,"INSERT INTO classes (className, classNumber, section, classCategory)
VALUES ('$name','$num','$section','$category')");
$classTemp = mysqli_query($con,"SELECT id FROM classes where className='$name' and classNumber='$num' and section ='$section'");
$classTempArray = mysqli_fetch_array($classTemp);
$classId = $classTempArray['id'];
mysqli_query($con,"INSERT INTO professors (name, classes) VALUES ('$name','$classId')");
$profTemp = mysqli_query($con,"SELECT id FROM professors where name='$name'");
$profTempArray = mysqli_fetch_array($profTemp);
$profId = $classTempArray['id'];
mysqli_query($con,"INSERT INTO classes (professor) VALUES ('$profId') where id ='$classId'");
}
else
{
$profName = $row['id'];
mysqli_query($con,"INSERT INTO classes ($profName, className, classNumber, section, classCategory)
VALUES ('$prof', '$name','$num','$section','$category')");
}
?>