Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    229
    Plugin Contributions
    0

    Default mysql_num_rows error

    As I'm in the process of upgrading to 1.5.4 on a server running PHP 5.6 this
    Code:
    if( mysql_num_rows( mysql_query("SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'"))){
        $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
        $db->Execute($sql);
    }
    (which is Super_orders' init_so_config.php) fire me with

    PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /ADMIN/includes/init_includes/init_so_config.php on line 13
    .

    Would this replacement work and is it the write syntax ?

    Code:
    $sql = "SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'";
    	$result = $db->Execute($sql);
    	$row_cnt = $result->num_rows;
    	if($row_cnt){
        $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
        $db->Execute($sql);
    }
    Thanks for your help

    Hubert

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: mysql_num_rows error

    Quote Originally Posted by hubert View Post
    As I'm in the process of upgrading to 1.5.4 on a server running PHP 5.6 this
    Code:
    if( mysql_num_rows( mysql_query("SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'"))){
        $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
        $db->Execute($sql);
    }
    (which is Super_orders' init_so_config.php) fire me with

    .

    Would this replacement work and is it the write syntax ?

    Code:
    $sql = "SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'";
        $result = $db->Execute($sql);
        $row_cnt = $result->num_rows;
        if($row_cnt){
        $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
        $db->Execute($sql);
    }
    Thanks for your help

    Hubert
    No, it would not, also if you were to look at the forum thread for the plugin then would see that there is/should be a version available that is compatible to 1.5.4 simplifying your effort... and really? this code doesn't use a table define but instead the table format from below? Wow, didn't realize it needed that kind of upgrading...

    a rewrite of this could be:
    Code:
        $sql = "SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'";
        $result = $db->Execute($sql);
        $row_cnt = $result->RecordCount();
        if(!$result->EOF && $row_cnt > 0){
          $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
          $db->Execute($sql);
        }
    That is if $row_cnt is used further below... If not then it could be reduced to something like:
    Code:
        $sql = "SHOW TABLES LIKE '".DB_PREFIX."so_payment_types'";
        $result = $db->Execute($sql);
        if(!$result->EOF && $result->RecordCount() > 0){
          $sql = "TRUNCATE TABLE ".DB_PREFIX."so_payment_types";
          $db->Execute($sql);
        }
    But there probably is another way that it has been incorporated or otherwise done... Again, suggest looking at the work that has already been done which will also simplify future upgrades...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Mar 2005
    Posts
    229
    Plugin Contributions
    0

    Default Re: mysql_num_rows error

    Thank you very much mc12345678.

    I had made a search on the forum for this function but I didn't find anything usefull in the answers.
    Now that I've read the support thread, you're right, I'm not the first one to face this.

    Thanks again for your code advices it helps me understand things

    Hubert

 

 

Similar Threads

  1. Replies: 2
    Last Post: 15 Feb 2012, 09:08 PM
  2. UPS XML Error: cURL: Error [77]: error setting certificate verify locations
    By ultraloveninja in forum Addon Shipping Modules
    Replies: 3
    Last Post: 30 Nov 2009, 03:55 AM
  3. Replies: 4
    Last Post: 30 Aug 2009, 09:26 PM
  4. php code for counting records (mysql_num_rows) -->
    By mac8mypc in forum General Questions
    Replies: 5
    Last Post: 4 Feb 2008, 06:02 PM
  5. Fatal error: mysql_num_rows()
    By fred385 in forum Installing on a Linux/Unix Server
    Replies: 0
    Last Post: 9 Nov 2006, 06:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR