php_begins Posted February 13, 2012 Share Posted February 13, 2012 I have the following code $hidden_client_id_query = mysql_query("SELECT id from `pdp_client_info` WHERE lead_id='$post_lead_id'"); $hidden_client_id=mysql_fetch_assoc($hidden_client_id_query); $this->view->hidden_client_id=$hidden_client_id['id']; I get the following error for the above code. I wonder where I am wrong. I am getting the $post_lead_id as expected. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/ Share on other sites More sharing options...
scootstah Posted February 13, 2012 Share Posted February 13, 2012 Because the query failed due to an error. After mysql_query, run echo mysql_error(); Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317913 Share on other sites More sharing options...
AyKay47 Posted February 13, 2012 Share Posted February 13, 2012 also, i like to keep the sql and query call in separate variables, that way if an error occurs in the query, I can output both the SQL and the mysql_error() call. Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317914 Share on other sites More sharing options...
php_begins Posted February 13, 2012 Author Share Posted February 13, 2012 My bad..That was a database access problem in the ZEND framework. I had to modify my code according to the settings in my framework. $hidden_client_id_query = $this->db->query("SELECT id FROM pdp_client_info WHERE lead_id='$post_lead_id'"); $hidden_client_id=$hidden_client_id_query->fetch(); $this->view->hidden_client_id=$hidden_client_id['id']; Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317919 Share on other sites More sharing options...
scootstah Posted February 14, 2012 Share Posted February 14, 2012 So is it fixed? Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317956 Share on other sites More sharing options...
php_begins Posted February 14, 2012 Author Share Posted February 14, 2012 oh yes..The code that I reposted works for me. Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317972 Share on other sites More sharing options...
scootstah Posted February 14, 2012 Share Posted February 14, 2012 In the future, the little "topic solved" button helps us know the problem is resolved. Quote Link to comment https://forums.phpfreaks.com/topic/257085-mysql_fetch_assoc-warning/#findComment-1317978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.