插入查询崩溃?
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$title = $_REQUEST['TitleFieldToAdd'];
$thread = $_REQUEST['ThreadFieldToAdd'];
$file_content = file_get_contents($_FILES['files']['tmp_name'][0]);
$file_name = $_FILES['files']['name'][0];
$file_size = $_FILES['files']['size'][0];
$file_type = $_FILES['files']['type'][0];
$date = date("Y-m-d");
if(!$link = new mysqli('localhost', 'root', 'root', 'DBFORTEST'))
{
printf("Connecting To DB Has Failed. Error Msg: %s", mysql_error($link)); exit;
}
$query = "INSERT INTO `DBFORTEST`.`News` (`id`, `title`, `thread`, `imageContent`, `imageName`, `imageType`, `imageSize`, `date')
VALUES (NULL , '$title', '$thread', '$file_content', '$file_name', '$file_type', '$file_size', '$date');";
if ($result = mysqli_query($link, $query)) {
echo("SUCCEEDED");
}else
{
echo("FAILED");
}
?>
我可以创建一个包含要插入的 blob 信息的查询...但它不起作用:( 看起来 mysqli_query() 崩溃了,但我找不到发生这种情况的原因。 这是因为查询太长了吗?因为 blob 图像信息?
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$title = $_REQUEST['TitleFieldToAdd'];
$thread = $_REQUEST['ThreadFieldToAdd'];
$file_content = file_get_contents($_FILES['files']['tmp_name'][0]);
$file_name = $_FILES['files']['name'][0];
$file_size = $_FILES['files']['size'][0];
$file_type = $_FILES['files']['type'][0];
$date = date("Y-m-d");
if(!$link = new mysqli('localhost', 'root', 'root', 'DBFORTEST'))
{
printf("Connecting To DB Has Failed. Error Msg: %s", mysql_error($link)); exit;
}
$query = "INSERT INTO `DBFORTEST`.`News` (`id`, `title`, `thread`, `imageContent`, `imageName`, `imageType`, `imageSize`, `date')
VALUES (NULL , '$title', '$thread', '$file_content', '$file_name', '$file_type', '$file_size', '$date');";
if ($result = mysqli_query($link, $query)) {
echo("SUCCEEDED");
}else
{
echo("FAILED");
}
?>
I could create a query with blob information to insert... but it doesn't work :(
It seems like mysqli_query() crashes but I cannot find a reason why this is happening.
Is this because the query is way too long? Because of blob image info?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
尽量不要使用mysql关键字作为列名。例如“date”这里
您的查询中存在语法错误:
线程
、imageContent
、imageName
、imageType
、imageSize
、`日期'应该用 ` 而不是'
Try not to use mysql keywords as column names. eg 'date' here
there is syntax error in your query :
thread
,imageContent
,imageName
,imageType
,imageSize
, `date'should be with ` instead of '