Home  >  Article  >  Backend Development  >  提取含字母用户名数据出错的有关问题

提取含字母用户名数据出错的有关问题

WBOY
WBOYOriginal
2016-06-13 12:27:161101browse

提取含字母用户名数据出错的问题

本帖最后由 wuzhi456 于 2015-11-10 22:21:50 编辑 在用户登录后,我用以下语句提取已登录用户的数据:
include("IncDB.php"); 
session_start () ;
$result=mysql_query("SELECT * FROM userlinks where id='a02' and userid=".$_SESSION['id']." order by datetime desc limit 1",$link);
$row = mysql_fetch_row($result);
echo "$row[1]"; 
echo"
"; 
echo "$row[2]";

mysql_close($link); 
?> 

问题是当全数字用户登录时能正确显示所提取的数据,但如果用户名含字母或汉字,显示内容为空,什么都没有;并且还报错:Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in....为什么?

我的数据库和网页都是用的UTF-8编码。数据库里面是有数据的,不是为空。谢谢我快疯了。。。。
------解决思路----------------------
<br />$_SESSION['id'] = 'abc123';<br />$sql = "SELECT * FROM userlinks where id='a02' and userid=".$_SESSION['id']." order by datetime desc limit 1";<br />echo $sql; //自己看看userid字段的值有没有用引号括起来<br />

------解决思路----------------------
userid='".$_SESSION['id']." 'order 这样是不行的
要 userid='".$_SESSION['id']."' order 这样
不然就多了个空格又查不到了

我能各给两位30么
不行,除非你给帖子加分!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn