sarathwhr Posted July 16, 2013 Share Posted July 16, 2013 Hello, I am getting the following error: ====Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/user/public_html/magento-db-repair-tool-1.1.php on line 378 Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/user/public_html/magento-db-repair-tool-1.1.php on line 391==== I believe it is something with the code since I haven’t touched that file. A quick googling also lead me to the same conclusion. Please help. Pasting lines below (from 378 to 391) :==== while($row = mysql_fetch_row($res)) {$tableProp[’fields’][$row[0]] = array(‘type’ => $row[1],‘is_null’ => strtoupper($row[3]) == ‘YES’ ? true : false,‘default’ => $row[5],‘extra’ => $row[6],‘collation’ => $row[2],);} // create sql$sql = “SHOW CREATE TABLE `{$tableName}`”;$res = mysql_query($sql, $this->_getConnection($type));$row = mysql_fetch_row($res);==== Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
web_craftsman Posted July 16, 2013 Share Posted July 16, 2013 Before this: while($row = mysql_fetch_row($res)) { $res has to be a correct result of mysql_query. You need to check for mysql errors. Do it like this: $res = mysql_query($query) or die('Error:' . mysql_error()) Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/#findComment-1440874 Share on other sites More sharing options...
sarathwhr Posted July 16, 2013 Author Share Posted July 16, 2013 Hello, Thanks for your reply. My code is :====// collect fields $sql = "SHOW FULL COLUMNS FROM `{$tableName}`"; $res = mysql_query($sql, $this->_getConnection($type)); while($row = mysql_fetch_row($res)) { $tableProp['fields'][$row[0]] = array( 'type' => $row[1], 'is_null' => strtoupper($row[3]) == 'YES' ? true : false, 'default' => $row[5], 'extra' => $row[6], 'collation' => $row[2], ); } // create sql $sql = "SHOW CREATE TABLE `{$tableName}`"; $res = mysql_query($sql, $this->_getConnection($type)); $row = mysql_fetch_row($res); $tableProp['create_sql'] = $row[1];====Can you tell me where exactly modification is needed? Replace $res = mysql_query($sql, $this->_getConnection($type)); with$res = mysql_query($query) or die('Error:' . mysql_error()) ? Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/#findComment-1440877 Share on other sites More sharing options...
sarathwhr Posted July 16, 2013 Author Share Posted July 16, 2013 Hello, I tried replacing $res = mysql_query($sql, $this->_getConnection($type)); with $res = mysql_query($sql, $this->_getConnection($type)) or die('Error:' . mysql_error()); But, same result I am not sure if that is what you asked me to try. Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/#findComment-1440878 Share on other sites More sharing options...
web_craftsman Posted July 16, 2013 Share Posted July 16, 2013 $res = mysql_query($sql, $this->_getConnection($type)) or die('Error:' . mysql_error($this->_getConnection($type))); Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/#findComment-1440882 Share on other sites More sharing options...
sarathwhr Posted July 16, 2013 Author Share Posted July 16, 2013 Thanks a TON....!!!! Link to comment https://forums.phpfreaks.com/topic/280186-mysql_fetch_row-expects-parameter-1-to-be-resource/#findComment-1440885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.