nvee Posted November 19, 2009 Share Posted November 19, 2009 I get a mysql_fetch_array() expects parameter 1 to be resource, boolean given in .... error when I run the following code. $q is passed to the page, and I have echoed it and returns a "3", which is what it is suppose to do. I cannot see what the problem is, everything else looks right. I predict it has to do with my sql query, but unless im missing something (which i am) I cannot see what the problem is Help anyone? dbconnect($server,$dbuser,$dbpass,$db); $query =mysql_query("SELECT * FROM city WHERE province_id = $q"); while ($result = mysql_fetch_array($query)) { echo "<option value=\"" . $result["id"] . "\">" . $result["name"] . "</option>"; } Link to comment https://forums.phpfreaks.com/topic/182137-solved-mysql_fetch_array-problem-with-sql-code/ Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2009 Share Posted November 19, 2009 where is $q initialized also put a die statement $query =mysql_query("SELECT * FROM city WHERE province_id = $q") or die("Cannot execute:".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/182137-solved-mysql_fetch_array-problem-with-sql-code/#findComment-960932 Share on other sites More sharing options...
nvee Posted November 19, 2009 Author Share Posted November 19, 2009 found the problem, it never connected to the database server properly! Link to comment https://forums.phpfreaks.com/topic/182137-solved-mysql_fetch_array-problem-with-sql-code/#findComment-960936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.