slawrence10 Posted August 10, 2009 Share Posted August 10, 2009 $product_orders_options = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_product_id = '" .(int)$product_id. "' AND name = '" . $thedate . "' AND value = '".$product_option_value['product_option_value_id']."'"); echo mysql_num_rows($product_orders_options); I've tried to do a simple query and then count the results but i'm getting the following error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /homepages/32/d126974997/htdocs/kwtables/catalog/model/catalog/product.php on line 205 any idea why the row count isn't working? Thanks for your time, Scott Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/ Share on other sites More sharing options...
Maq Posted August 10, 2009 Share Posted August 10, 2009 Can you echo out your query? It's failing. Look like when you prefix "DB_PREFIX" it's concatenating it to the table rather than specifying the DB name. Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895091 Share on other sites More sharing options...
slawrence10 Posted August 10, 2009 Author Share Posted August 10, 2009 i done a print of DB_PREFIX which comes out as kwOC and the table is kwOCorder_option so that should be fine did I understand you right there? :/ thanks, Scott Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895096 Share on other sites More sharing options...
Maq Posted August 10, 2009 Share Posted August 10, 2009 When I see DB_PREFIX I think of a format like this: kwOC.order_option DB_PREFIX being the database (DB) and order_option being the table name. Notice the dot between the database name and the table name. That's how I would interpret your code. Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895097 Share on other sites More sharing options...
slawrence10 Posted August 10, 2009 Author Share Posted August 10, 2009 ah no that's not the case all my other query's have been formatted in that way and work fine :/ Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895100 Share on other sites More sharing options...
Andy-H Posted August 10, 2009 Share Posted August 10, 2009 $product_orders_options = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_product_id = '" .(int)$product_id. "' AND name = '" . $thedate . "' AND value = '".$product_option_value['product_option_value_id']."'"); echo mysql_num_rows($product_orders_options);//look <<< Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /homepages/32/d126974997/htdocs/kwtables/catalog/model/catalog/product.php on line 205 Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895102 Share on other sites More sharing options...
slawrence10 Posted August 10, 2009 Author Share Posted August 10, 2009 sorry that's just me being a retard between trying things and copying the wrong stuff the error is: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/32/d126974997/htdocs/kwtables/catalog/model/catalog/product.php on line 203 so yes my topic is now wrong :/ Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895106 Share on other sites More sharing options...
Andy-H Posted August 10, 2009 Share Posted August 10, 2009 So the code is part of a class, yes? Can you show the query method please. Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895112 Share on other sites More sharing options...
Maq Posted August 10, 2009 Share Posted August 10, 2009 Can you echo out your query? Also, make sure that your query method is returning a resource id, just echo that out as well and paste the exact output for both. Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895115 Share on other sites More sharing options...
slawrence10 Posted August 10, 2009 Author Share Posted August 10, 2009 ah yes you've just found my problem lol Undefined property: DB::$query Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895120 Share on other sites More sharing options...
slawrence10 Posted August 10, 2009 Author Share Posted August 10, 2009 I'm a bit confused though, basically I'm editing a controller file within OpenCart and have just taken the format of the other queries which use $this->db->query is it maybe because $this->db->query has already been called once in that given function? Regards, thanks for your help! Scott Quote Link to comment https://forums.phpfreaks.com/topic/169669-mysql_fetch_row/#findComment-895125 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.