在以下代码中,我收到以下错误:
无法获取 mysqli_stmt
// assign
$title = 'this is the title';
$caption = 'description goes here...';
$filename = '43534b34.jpg';
$thumb = array();
$thumb['basename'] = null;
$thumb['width'] = 0;
$thumb['height'] = 0;
// insert new record in db
$sql = 'INSERT INTO image (title, caption, filename, thumb_filename, thumb_width, thumb_height) VALUES(?, ?, ?, ?, ?, ?)';
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param('ssssii', $title, $caption, $filename, $thumb['basename'], $thumb['width'], $thumb['height']);
$stmt->execute();
如果我替换数组中的键 $thumb['basename'] = 'test';
,那么一切正常!
如何将 NULL 值分配给数据库表中的列?