我一般不采用这种写法,我的写法如下:header('Content-Type:text/html;charset=gb2312');
$conn=mysql_connect("127.0.0.1","root","lc")or die("不能连接数据库");
mysql_select_db("test") or die("不能选择数据库");
mysql_query("set names 'gb2312'");
$query=@mysql_query("select content from info where content like '%". $_REQUEST[info]."%' order by id ");
while($array=@mysql_fetch_array($query)){
...
}
本机测试过,没有问题
$conn=mysql_connect("127.0.0.1","root","lc")or die("不能连接数据库");
mysql_select_db("test") or die("不能选择数据库");
mysql_query("set names 'gb2312'");
$query=@mysql_query("select content from info where content like '%". $_REQUEST[info]."%' order by id ");
while($array=@mysql_fetch_array($query)){
...
}
本机测试过,没有问题
//数据库:db_QS_OA
//表:t_corporationinfo
//字段:corporation_name
/////////////////////////////////代码/////////////////////////////////////
$localhost = "localhost";
$username = "root";
$password = "llg"; $db_cnd = new mysqli($localhost,$username,$password);
$db = "db_QS_OA"; //数据库名
$db_cnd->select_db($db);
if($result = $db_cnd->query("select corporation_name from t_corporationinfo")) //SQL查询在数据库里查询通过
{
while($row = $result->fetch_array())
{
printf("test resualt is %s",$row["corporation_name"]);
}
$result->close();
}
$db_cnd ->close(); ?>本机测试没有问题,你再比较一下。
我终于明白了,我在UE和DW3切换着编辑这个程序.
////////////////////////////////////////////
while($row = $result->fetch_array())
{
printf("test resualt is %s",$row["corporation_name"]);
}
////////////////////////////////////////////
在
" }"
这一行里的空格可能是空格有问题,