M
M
michellie2017-09-21 20:20:29
PHP
michellie, 2017-09-21 20:20:29

What's wrong, everything works but there is a warning?

everything works correctly, the script is executed, but among other things it spams the warnings page

$otvet = mysql_query($sql);
if (mysql_num_rows($sql)>0){
            while($row = mysql_fetch_assoc($otvet)){
 			echo "<div class=\"visualp\">
     <p>{$row['num']}</p><h2>{$row['name']}</h2><div class=\"raterightside\"><i class=\"fa fa-arrow-down fa-lg\" aria-hidden=\"true\"></i><i class=\"fa fa-arrow-up fa-lg\" aria-hidden=\"true\"></i></div><div class=\"ratenum ";
    $color = $row['rating'];

     	if ($color > 0) {
     		echo "green";
     	}
     	
     	elseif ($color < 0) {
     		echo "red";
     	}
     	
     	else {
     		echo "grey";
     	}
     	


     echo "\"><p>{$row['rating']}</p></div>
     </div>";
}
}
  else {
    echo "<div class=\"visualp\">
    <h2>+++ ДОБАВИТЬ +++</h2></div>";
}

"Warning: mysql_num_rows() expects parameter 1 to be resource" but, again, everything works correctly, I xs, the whole page is in these warnings (it all started when I set IF, ELSE, tried !== and =0, all the same and the same, it works but the warnings

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
michellie, 2017-09-21
@michellie

If someone encounters this problem, everything is solved very simply:

if ($row = mysql_fetch_assoc($otvet)) {
while {}
}
else{}

I
iRedds, 2017-09-21
@iRedds

How about reading the documentation and stop stuffing the non-pushable into the argument?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question