Jump to content

INNER JOIN GOT error for mysql_fetch_array()


jimjack145

Recommended Posts

 

Hi ALL,

 

When i run below code then i got and error as below:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/datalist_year.php on line 21

 

I am not getting y i got such an error. Any guidance and assist welcome.

 

Regards,

JIMI

-----------------------------------------------------------

<?PHP

 

$loginname = ''";

 

$password = "";

 

$database = "";

 

$con = mysql_connect("localhost", "$loginname", "$password") or die("could not connect");

mysql_select_db("$database");

 

$query = "SELECT candidate.first_name, candidate.last_name, candidate_foreign.value from candidate, candidate_foreign INNER JOIN candidate_foreign ON candidate.candidate_id = candidate_foreign.assoc_id WHERE candidate_foreign.field_name = 'IITYear' AND value >= '" .$_POST['from']. "' AND '".$_POST['to']."'";

 

$result = mysql_query ("$query");

 

echo "You are seaching between year '" .$_POST['from']. "' to '" .$_POST['to']. "'";

 

echo "<TABLE BORDER=1><TH>First Name</TH><TH>Last Name</TH><TH>Cell No</TH><TH>Email</TH>";

 

 

  while ($in = mysql_fetch_array($result))

      {

        echo "<TR>";

        echo "<TD>" . $in[first_name] . "</TD>";

        echo "<TD>" . $in[last_name] ."</TD>";

        echo "<TD>" . $in[value] ."</TD>";

        echo "</TR>";

      }

 

echo "</TABLE>";

 

mysql_close($con);

 

?>

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.