简体   繁体   English

mysql where语句在phpmyadmin中工作,但不在站点上

[英]mysql where statement working in phpmyadmin but not on site

I have this query: 我有这个查询:

$res=mysql_query("SELECT * FROM `t_modules` WHERE nPageM='61'") or die(mysql_error());

In phpmyadmin it returns (as expected) 2 rows but on page it returns 0. If i use 在phpmyadmin中它返回(按预期)2行,但在页面上它返回0。如果我使用

$res=mysql_query("SELECT * FROM `t_modules` WHERE nPageM<>'61'") or die(mysql_error());

or 要么

$res=mysql_query("SELECT * FROM `t_modules`") or die(mysql_error());

it runs on the page correctly it's just the WHERE and = combination that doesn't work I also checked that the type for nPageM is int(11) 它在页面上正确运行,只是WHERE和=组合不起作用,我还检查了nPageM的类型是否为int(11)

UPDATE 更新

I can run comparisons on other columns in the table but not on nPageM 我可以在表中的其他列上运行比较,但不能在nPageM上运行

$res=mysql_query("SELECT * FROM `t_modules` WHERE id_md='5'") or die(mysql_error());

Is working. 正在工作。 But i still don't have a clue about why it's not working on the nPageM column 但是我仍然不知道为什么它在nPageM列上不起作用

have you ensured that you have included a connection to the databse in your php script before running this code? 您是否已确保在运行此代码之前已在php脚本中包括到数据库的连接?

<?php
$con = mysql_connect('sqluser', 'sqlpassword', 'sqlserver');
$db = mysql_select_db('dbame', $con);

//now, make sure it's connecting
if (!$con) {
die('mysql connection error' . mysql_error());
}
if (!$db) {
die('mysql Database error' . mysql_error());
}
?>

而是尝试将方括号括起来:

$res=mysql_query("SELECT * FROM `t_modules` WHERE (nPageM<>'61') ") or die(mysql_error());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM