mysql_fetch_array
无效。一切都很好看。我不知道我在做错什么。
$sql = "SELECT * FROM `$tbl_name` limit $start,$limit";//if echo gives o/p Resource id #14
$resultw = mysql_query($sql);
while($gup=mysql_fetch_array($resultw))//if echo gives o/p Array
{
//if echo $gup['to']; gives o/p vicky.0989hyd@gmail.com;
$anusha=mysql_query("select * from users where email='$gup[to]'");//if echo gives o/p Resource id #15
while($resulter = mysql_fetch_array('$anusha'))//here is what iam getting error Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in
{
}
}
有人可以帮助我在mysql_fetch_array
找到我的错误吗?
答案 0 :(得分:0)
您应该尝试非常仔细地理解以下代码。这个目前正在我的社交网站上使用,我希望这能解决你的问题。
$st= "SELECT* FROM users WHERE username='$you'";
$result=mysqli_query ($con,$st);
$count=mysqli_num_rows ($result);
if($count==0){echo "<b>Profile not found! </b> ";}
else {echo "<b>Your Profile..</b>";}
while($row= mysqli_fetch_array ($result)) { echo "Username-<b>". $row ['uname']. "</b>"; echo "sent you this message";
echo "<p id='sms'>". $row ['sms']. "</p>";
答案 1 :(得分:0)
尝试这种方式......我认为你正在搞乱单引号和双引号
$sql = "SELECT * FROM `$tbl_name` limit $start,$limit";
$resultw = mysql_query($sql);
if (!$resultw) {
die('Invalid query: ' . mysql_error());
}
while($gup=mysql_fetch_array($resultw))//if echo gives o/p Array
{
$email=$gup['to'];
$anusha=mysql_query("select * from users where email='$email'");
if (!$anusha) {
die('Invalid query: ' . mysql_error());
}
//check $anusha here before pass it to mysql_fetch_array function
while($resulter = mysql_fetch_array($anusha))
{
//do what you want to do man
}
}
答案 2 :(得分:0)
您可以查看查询中是否有任何错误:mysql_error();
此函数返回与mysql相关的函数中的最后一个错误。
只需使用以下语法:
$resultw = mysql_query($sql) or die(mysql_error());
$gup=mysql_fetch_array($resultw) or die(mysql_error());
while($gup)//if echo gives o/p Array
{
$email=$gup['to'];
$anusha=mysql_query("select * from users where email='$email'") or die(mysql_error());
//check $anusha here before pass it to mysql_fetch_array function
...
}