I am trying to update a Mysql database. $conference is a boolean(tinyint).
The problem is:
If I click the box, it has this message when I submit:
UPDATE contacts SET contact = ‘on’ WHERE contact_id = 3Error: Incorrect integer value: ‘on’ for column ‘contact’ at row 1
If I try to send an empty checkbox, I get this after submit:
Notice: Undefined index: conference in C:\check.php on line –
UPDATE contacts SET contact = ‘’ WHERE contact_id = 3Error: Incorrect integer value: ‘’ for column ‘contact’ at row 1
Any help would be appreciated. I have struggled with this.
<?php
if (isset($_POST['submit'])) {
$scheduleid = $_POST['scheduleid'];
$conference = $_POST['conference'];
$sql = "UPDATE contacts SET
contact = '$conference'
WHERE contact_id = $scheduleid";
ECHO $sql;
IF (mysql_query($sql)) {
ECHO "Game details updated.";
} ELSE {
ECHO "Error: " . mysql_error();
EXIT;
}
ECHO "<P><A HREF=\\"check.php\\">Back</A></P>";
}
ELSE
{
$scheduleid = 3;
$reportdata = mysql_query("SELECT * FROM contacts WHERE contact_id = $scheduleid");
IF (!$reportdata) {
ECHO ("<P>Error fetching game details: " .
mysql_error() . "</P>");
EXIT();
}
$info = mysql_fetch_array($reportdata);
$id = $info['contact_id'];
$conference = $info['contact'];
?>
<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST">
<TABLE>
<TR>
<TD align=right valign=top><b>Conference:</b></TD>
<TD><INPUT TYPE="checkbox" NAME="conference" <?php if ($conference){ECHO "CHECKED";}?>></TD>
</TR>
</TABLE>
<BR />
<INPUT TYPE=HIDDEN NAME="scheduleid" VALUE="<?php echo $scheduleid; ?>">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
<BR />
</FORM>
<?PHP
}
?>