sagisgirl Posted December 24, 2012 Share Posted December 24, 2012 I am getting the following error and can not figure out why: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource so, i made a bit changes to my code here $rs_recTuser = mysql_query($query_recTuser) to this $rs_recTuser = mysql_query($query_recTuser) or die ('Query failed: ' . mysql_error(). "<br />\n$query_recTuser"); then a new error came : Query failed: Unknown column 'tenantID' in 'where clause' SELECT * FROM u_user WHERE tenantID = 9 here is my code: $query_recTuser = "SELECT * FROM u_user WHERE tenantID = ".$tenantID; $rs_recTuser = mysql_query($query_recTuser) or die ('Query failed: ' . mysql_error(). "<br />\n$query_recTuser"); $totalRows_recTuser = mysql_num_rows($rs_recTuser); Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/ Share on other sites More sharing options...
Pikachu2000 Posted December 24, 2012 Share Posted December 24, 2012 Evidently, there is no field by the name tenantID in your table. Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401077 Share on other sites More sharing options...
sagisgirl Posted December 24, 2012 Author Share Posted December 24, 2012 thank you..it worked fine now..thanks... but i got another error.: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource here is the code $query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = ".$tenantID; $rs_recTenantID = mysql_query($query_recTenantID); $recTenantID = mysql_fetch_array($rs_recTenantID); why is that error occur..? Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401082 Share on other sites More sharing options...
MDCode Posted December 24, 2012 Share Posted December 24, 2012 Your query is failing add echo mysql_error(); after mysql_query($query_recTenantID); Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401085 Share on other sites More sharing options...
sagisgirl Posted December 24, 2012 Author Share Posted December 24, 2012 is it like this $query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = ".$tenantID; $rs_recTenantID = mysql_query($query_recTenantID); echo mysql_error(); $recTenantID = mysql_fetch_array($rs_recTenantID); still got the error.. im new in php..so please do understand me... Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401086 Share on other sites More sharing options...
Jessica Posted December 24, 2012 Share Posted December 24, 2012 What error did you get? Your original error was that tenantID is not a column. If it's not, either create it or figure out what column you wanted. Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401093 Share on other sites More sharing options...
sagisgirl Posted December 24, 2012 Author Share Posted December 24, 2012 i already create column for tenantID... the error is still the same even after i add echo mysql_error(); here are the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401098 Share on other sites More sharing options...
Christian F. Posted December 24, 2012 Share Posted December 24, 2012 If you echo out the SQL query as well, you should notice what's missing from it. From there you should be able to determine what the problem is, and by tracing the problem upwards in the code you should find the cause. Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1401113 Share on other sites More sharing options...
sagisgirl Posted December 30, 2012 Author Share Posted December 30, 2012 ok...i did that echo like this.. $query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = ".$tenantID; $rs_recTenantID = mysql_query($query_recTenantID); while($recTenantID = mysql_fetch_array($rs_recTenantID)) { echo $recTenantID['tenantID']; } but still i got the same error... Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402109 Share on other sites More sharing options...
Jessica Posted December 30, 2012 Share Posted December 30, 2012 Read the link in my signature. You're not capturing MySQL errors. Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402114 Share on other sites More sharing options...
sagisgirl Posted December 30, 2012 Author Share Posted December 30, 2012 sorry jessica..but i didn't understand you... what do you mean by i'm not capturing mySQL errors..? Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402120 Share on other sites More sharing options...
sagisgirl Posted December 30, 2012 Author Share Posted December 30, 2012 ok i change my code to this.. $query_recTenantID = "SELECT * FROM md_tenant WHERE tenantID = ".$tenantID; $rs_recTenantID = mysql_query($query_recTenantID) or die ('Query failed: ' . mysql_error(). "<br />\n $query_recTenantID"); while($recTenantID = mysql_fetch_array($rs_recTenantID)) { echo $recTenantID['tenantID']; } then it give an error : Parse error: syntax error, unexpected ')' why..? Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402132 Share on other sites More sharing options...
Pikachu2000 Posted December 30, 2012 Share Posted December 30, 2012 The code you posted has no parse errors. It must be somewhere else. Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402138 Share on other sites More sharing options...
sagisgirl Posted December 30, 2012 Author Share Posted December 30, 2012 suddenly it give me a new error : Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 SELECT * FROM md_tenant WHERE tenantID = why...?? Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402141 Share on other sites More sharing options...
sowna Posted December 30, 2012 Share Posted December 30, 2012 tenantID is empty here... check the tenantID variable... Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402162 Share on other sites More sharing options...
sagisgirl Posted December 31, 2012 Author Share Posted December 31, 2012 yeayh..i just realized that, the variable is empty... ok,thanks for you helping...thanks guys... Link to comment https://forums.phpfreaks.com/topic/272325-query-failed-unknown-column-tenantid-in-where-clause/#findComment-1402269 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.