I get this error when I'm trying to insert a new record
Incorrect integer value: 'on' for column 'status' at row 1
Here is the PHP I'm using
if ($action == 'create')
{
$query = "INSERT INTO hosts (title, status) VALUES ('"
. mysqli_real_escape_string($mysqli, $title) . "', '"
. mysqli_real_escape_string($mysqli, $status) . "');";
//should use defaults for id and pubdate
}
else if ($action == 'update')
{
$query = "UPDATE hosts SET title='" . mysqli_real_escape_string($mysqli, $title) . "'"
. ", status='" . mysqli_real_escape_string($mysqli, $status) . "'"
. " WHERE id='" . mysqli_real_escape_string($mysqli, $id) . "';";
//timestamp doesnt change
}
else
echo 'Invalid action.';
//insert
if ($result = $mysqli->query($query))
{
if ($result->num_rows > 0)
{
echo 'It worked: ' . $result;
}
else
echo 'It failed: ' . $result;
$result->close();// free result set memory
}
else
echo $mysqli->error;
This is my hosts table
+---------+---------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------------+------+-----+-------------------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | | |
| status | tinyint(3) unsigned | NO | | | |
| pubdate | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+---------------------+------+-----+-------------------+----------------+
I dont know why its not working.
Windows 2000
PHP 5.2.3
MYSQL 5.0.37