jimjack145 Posted March 22, 2007 Share Posted March 22, 2007 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); ?> Link to comment https://forums.phpfreaks.com/topic/43809-inner-join-got-error-for-mysql_fetch_array/ Share on other sites More sharing options...
onlyican Posted March 22, 2007 Share Posted March 22, 2007 try this 2 Things $result = mysql_query($query); You dont need the " and also try this under that line if(!$result){ echo "Error.<br />\n".mysql_error(); } Link to comment https://forums.phpfreaks.com/topic/43809-inner-join-got-error-for-mysql_fetch_array/#findComment-212684 Share on other sites More sharing options...
jimjack145 Posted March 22, 2007 Author Share Posted March 22, 2007 hi Thks for your reply i have done from my side and that works pretty good. Once again thks for your reply. Jimi Link to comment https://forums.phpfreaks.com/topic/43809-inner-join-got-error-for-mysql_fetch_array/#findComment-212701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.