0

我正在从$number_column变量中的 excel 表中读取值

$number_column = $data->sheets[0]['cells'][$row1][1];

然后进行选择查询

$query_patent = "SELECT `id` FROM `ipoverview` WHERE number ='$number_column'";

它不工作。如果我回显我$number_column的数据,我将在该位置获取数据。

如果将任何数字硬编码为$number_column,则该查询正在执行。

 $number_column="12345";
 echo $query_patent = "SELECT `id` FROM `ipoverview` WHERE number ='$number_column'"; //This works

帮我解决这个问题??

4

3 回答 3

1

确保您将 UTF-8 作为 excel 文件的字符编码,并确保您应该将 utf8_general_ci 作为数据库列的排序规则以获取更多信息,请参阅http://docs.php.net/manual/en /mysqli.set-charset.php。谢谢

于 2013-01-09T13:57:12.307 回答
0

试试这个。还有echo $query_patent在执行查询之前你是否在该变量上获取一个变量。

echo $query_patent = "SELECT `id` FROM `ipoverview` WHERE number ='".$number_column."'";

上述回声的响应

SELECT `id` FROM `ipoverview` WHERE number = 'E1234A'    
SELECT `id` FROM `ipoverview` WHERE number = 'E1234B'
SELECT `id` FROM `ipoverview` WHERE number = 'E1234C'
于 2013-01-07T12:10:13.427 回答
0

你有这条线:

echo $query_patent = "SELECT `id` FROM `ipoverview` WHERE number ='$number_column'";

不应该是这样的:

$query_patent = "SELECT `id` FROM `ipoverview` WHERE number ='$number_column'";
$rResult = mysqli_query($dblink,$query_patent)or die("something went wrong when executing this query:<br /><br />" + $query_patent + "<br /><br />"+ mysqli_error($dbLink));
// Dot Stuff with $rResult
while($row = mysqli_fetch_row($rResult)){
    print_r($row);
}
于 2013-01-07T12:11:52.453 回答