-1

My code is as following:

$br_code=$_SESSION["br_code"];
echo $sqlstr="select DISTINCT branch_assets.s_id,s_name
              from branch_assets,assets
              where assets.s_id=branch_assets.s_id and
              br_code='$br_code'";
echo $result=mysql_query($sqlstr);
while($row1=mysql_fetch_array($result))
{
}

But on the line of while loop it show me warning as

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\System_management\send_in_maintanance1.php

where is my mistake please help to find this.

Smit Saraiya
  • 391
  • 1
  • 5
  • 26

1 Answers1

3
$sqlstr="select DISTINCT branch_assets.s_id,s_name from branch_assets,assets where assets.s_id = branch_assets.s_id and br_code='".$br_code."'";

It's best to switch to either mysqli or PDO with a prepared statement instead of mysql_, since it is deprecated and deleted from PHP 7.0.

Reference:

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Mike Wight
  • 56
  • 1
  • 4
  • 8