Error with mysql_fetch_array: wait for a resource but get Boolean

0

I have this error in my code:

  

Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in ... on line ...

It seems to be the syntax of the sql array line, but I do not see how to fix it. Does anyone know what the problem is?

Here my code:

<div class="section">
<?php
$numCedula = htmlentities($row['NumCedula'],ENT_QUOTES,'utf-8');
$sql="SELECT * FROM users WHERE Patrocinador = {$numCedula}";
$result = mysql_query($sql) ;
//echo [$result];
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
    <div class="mis_afiliados_1">
        <a> 
            <img src="<?php echo $row['avatar'];?>" alt="Avatar" /><br>   
            <?php echo $row['nombre']; ?><br>
            <?php echo date('d/m/Y',$row['signup_date']); ?>
        </a><br>
    </div>
<?php } ?>
</div>
    
asked by Jesunday 27.03.2017 в 09:41
source

1 answer

-1

It is not returning data mysql_fetch_array

  

Returns an array of strings that corresponds to the row retrieved, or   FALSE if there are no more rows.

Try this way:

$numCedula = htmlentities($row['NumCedula'],ENT_QUOTES,'utf-8');
$sql="SELECT * FROM users WHERE Patrocinador = " . $numCedula;

If you continue to fail, check that $ numCedula is correctly obtaining the data you are looking for.

    
answered by 27.03.2017 в 09:51