Search code examples
mysqlwhere-clause

where clause not working in mysql


when I run this

$data = mysql_query("SELECT * FROM smslogs  ");

$info = mysql_fetch_array( $data );

It's working fine. but when I run this

$data = mysql_query("SELECT * FROM smslogs WHERE ipaddress = '36.21.54.125' ");

above ipaddress my column name type varchar(255) in table smslogs.

It's not working even not go into below while loop

while($info = mysql_fetch_array( $data )) 

I have also tried this

$ip="36.21.54.125";

$data = mysql_query("SELECT * WHERE ipaddress = '". $ip . "' ");

but to no avail.

Can you help me please?


Solution

  • Thanks, guys problem resolved using the below code

    $sql = "SELECT * FROM `smslogs` WHERE rcpt = '$to'";
    
    $result = mysql_query( $sql, $conn );
    
    if( !$result )
    {
        die('Could not get data: ' . mysql_error());
    }
    

    It was a retrieval error.