MySQL LOAD_FILE返回NULL [英] MySQL LOAD_FILE returning NULL

查看:105
本文介绍了MySQL LOAD_FILE返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行此SELECT LOAD_FILE("/home/user/domains/example.com/public_html/robots.txt") AS tmp FROM tmpTable,但它返回NULL.如何检查这是因为我没有FILE特权还是其他原因? MySQL不会给出错误. (我正在使用PHP)

I'm doing this SELECT LOAD_FILE("/home/user/domains/example.com/public_html/robots.txt") AS tmp FROM tmpTable but it returns NULL. How can I check if this is because I haven't got the FILE privilege or if it's something else? MySQL won't give an error. (I'm using PHP)

任何具有LOAD_FILE经验的人,请告诉我该功能:)

Anyone that has experience with LOAD_FILE, tell me about that function:)

<?php
$result = mysql_query('SELECT LOAD_FILE("/home/user/domains/example.com/public_html/robots.txt") AS tmp FROM tmpTable') or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
var_dump( $row['tmp'] );
}

推荐答案

Linux发行版上的某些MySQL版本似乎具有LOAD_FILE函数的错误.这是线程.在线程的最后,似乎有一种解决方法.

Looks like some versions of MySQL on Linux distributions have a bug with the LOAD_FILE function. Here is the thread. At the very end of the thread looks like there might be a workaround.

由于您位于共享主机上,因此查看所需的功能可以直接读取文件吗?使用 file()应该会将文件读取为数组格式.

Since you're on a shared host, looking at the functionality you want could you just read the file instead? Using the file() should read the file into an array format.

这篇关于MySQL LOAD_FILE返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆