我在脚本中执行更新查询。它返回true,但更新查询不更新表。这是查询。我在这里错过了什么?更新查询不更新表
$connection = db::factory('mysql');
$query='update bookings SET date="'.$date.'",time_from="'.$time_from.'",time_to="'.$time_to.'",status="'.$status.'" where booker_id="'.$booker_id.'"';
if(mysql_query($query)) {
echo "success"; exit;
return true;
} else {
echo "fail"; exit;
return false;
}
这里是表结构
CREATE TABLE IF NOT EXISTS `bookings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time_from` time NOT NULL,
`time_to` time NOT NULL,
`status` varchar(250) NOT NULL,
`booker_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;
中的任何一个请显示生成的查询字符串和您的表结构。 –
您应该使用预处理语句查看PDO或MySQLi,因为mysql_函数已被弃用。 – Fredd
请勿使用mysql_ *使用mysqli_ *或PDO。 –