Jump to content

error unable to resolve


narjis

Recommended Posts

In the given code below I am getting this error

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\samples\getcustomers.php on line 20

WHY?

 

 

<?php
$value = $_GET["q"];
  $con = mysql_connect('localhost', 'root', ''); 
  //db_connect();
  if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  $db_selected = mysql_select_db("ajaxDb",$con);
  $sql = "SELECT * FROM 'cutomers' WHERE Name = '".$value."'";
// echo $sql;
$result = mysql_query($sql);
  echo "<table border='1'>
<tr>
<th>Name</th>
<th>Address</th>
<th>Country</th>
</tr>";
        
  while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['Address'] . "</td>";
  echo "<td>" . $row['Country'] . "</td>";
  echo "</tr>";
  }
  echo "</table>";
  mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/233025-error-unable-to-resolve/
Share on other sites

For whatever reason, your query is failing and returning a boolean FALSE as a result. Are you sure your connection and db selection are actually successful? You don't have any logic in place to make sure those 2 operations succeed before allowing the query to run.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.