I'm trying to add some values to my db. I know it's reaching that block of code, but it won't actually add the data to the db. The odd thing is, the same code works fine on my WAMP server.
The data is sanitized further up. I know I should use prepared queries too, that's what I'll work on next.
I don't know why it's not working, I've gone over it twice.
From regform.php:
if($result->num_rows == 1)
{
echo "updating records";
$sql = "UPDATE tblAAA";
$sql .= "SET memNumber='$memNumber',fName='$fname',lName='$lName', dob='$dob',
country='$country',";
$sql .= "street='$street',city='$city',state='$state', zip='$zip',email='$email',
phone='$phone',club='$club')";
$sql .= "WHERE memNumber = '$memNumber'";
}
else
{
echo "adding new record";
$sql = "INSERT INTO tblAAA ";
$sql .= "(memNumber,fName,lName,dob,country,street,city,state,zip,email,phone,club)";
$sql .= "VALUES($memNumber,'$fname','$lname','$dob','$country','$street','$city','$state',
'$zip','$email','$phone','$club')";
$conn->query($sql);
}
$sql2 = "INSERT INTO tblBBB";
$sql2 .= "(year, memNumber)";
$sql2 .= "VALUES('2015','123')";
$conn->query($sql);
$conn->query($sql2);
From view.php:
$sql = "SELECT * FROM tblAAA";
$result = $conn->query($sql);
...
while($row = $result->fetch_assoc())
{
echo "<tr>";
echo "<td><span class=\"history glyphicon glyphicon-plus\"></span></td>";
echo "<td>" . $row['fName'] . "</td>";
echo "<td>" . $row['lName'] . "</td>";
echo "<td>" . $row['dob'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['street'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['zip'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['memNumber'] . "</td>";
echo "<td>" . $row['club'] . "</td>";
echo "<td><span class=\"edit glyphicon glyphicon-pencil\"></td>";
echo "<td><span class=\"delete glyphicon glyphicon-remove\"></td>";
echo "</tr>";
}
echo "Results " . $result->num_rows;
Edit: The problem was that I named a column dofb, not dob. Is there a way to get php to display an error message for that sort of thing?