ivytony Posted February 11, 2008 Share Posted February 11, 2008 here's my query: //select the category the url belongs to $sql = "SELECT * from ". table_stores ." where domain=". $domain; $category_id = $db->get_results($sql); However, when I type in a domain name on web page, this query gives me this warning message: Warning: Unknown table 'circuitcity' in where clause in /public_html/libs/db.php on line 233 the code block in db.php is: if ( $str = @mysql_error($this->dbh) ) { $is_insert = true; $this->register_error($str); $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; //This line is 233 return false; } circuitcity is actually not even a table in mysql database. Domain is a column in the table of stores. Can someone help me figure out where is wrong? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/90515-weird-warning-message-for-mysql-query/ Share on other sites More sharing options...
toplay Posted February 11, 2008 Share Posted February 11, 2008 When using literal values you need to enclose them in quotes (single or double)...WHERE domain = '$domain' Also, I assume "table_stores" is defined as a constant. If it's just a variable, then you've forgotten the dollar sign. Quote Link to comment https://forums.phpfreaks.com/topic/90515-weird-warning-message-for-mysql-query/#findComment-464077 Share on other sites More sharing options...
ivytony Posted February 11, 2008 Author Share Posted February 11, 2008 yes, table_stores is a constant. Now it works, but I have problem fetching values <?php $category_id = $db->get_results($sql); //check if category id exists for the particular domain $categoryid = $category_id['category_id']; // category_id is a column in the database table _stores if (!$categoryid){ $categoryid = 0; } echo $categoryid; ?> This code gives me $categoryid = 0 even though there are records in the table. Am I missing something? thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/90515-weird-warning-message-for-mysql-query/#findComment-464091 Share on other sites More sharing options...
toplay Posted February 11, 2008 Share Posted February 11, 2008 Very unsatisfactory post. You need to be very clear with your questions if you expect members on this forum to respond to you. Issues with your post: 1) You don't show what the current query ($sql value) is. 2) We don't see where or how you're actually running the query (unless get_results() does it, but how are we supposed to know that?). 3) We don't know what get_results() does exactly. We don't know if you're using a database abstraction layer, a home grown function or what. 4) We don't know if get_results() really returns an array, resource object, or an object, or something else. It's up to you to help yourself by putting debug echo's in strategic places in your code to see where things are going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/90515-weird-warning-message-for-mysql-query/#findComment-464128 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.