Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2012
    Posts
    52
    Plugin Contributions
    0

    help question $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    here are two methods i've tested successfully
    i wanna know if i use METHOD B, will i get any insecurity ?


    PHP Code:
    $aaa_query ""select ..."; 
    METHOD A (zen cart default method)
    PHP Code:
    $aaa $db->Execute($aaa_query);
    while (!
    $aaa->EOF) {
      echo 
    $aaa->fields['bbb'];

    METHOD B
    PHP Code:
    $aaa mysql_query($aaa_query);
    while(
    $row mysql_fetch_array($aaa)){
      echo 
    $row['bbb'];


  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    If you go with option A (i.e. using the integrated Zen Cart database calls), you'll be future-proofed when the mysql* function calls are removed from a future PHP version (they're deprecated in PHP 5.5).

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    Method A is the best one to use within Zen Cart.

    But you've got an error in it. You're missing an important line, else you'll end up in an endless loop:
    Code:
    $aaa = $db->Execute($aaa_query);
    while (!$aaa->EOF) {
      echo $aaa->fields['bbb'];
      $aaa->MoveNext();
    }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Oct 2012
    Posts
    52
    Plugin Contributions
    0

    Default Re: $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    sorry i forgot writing $aaa->MoveNext(); just now


    yes, Method A is good for zen cart and i use this method for many files for my zen cart,
    but for one of my files, i get an issue by this method, then i have to try Method B, it works.
    i'm not sure Method B is safe enough, or will it bring any problem? in the future?

    Quote Originally Posted by DrByte View Post
    Method A is the best one to use within Zen Cart.

    But you've got an error in it. You're missing an important line, else you'll end up in an endless loop:
    Code:
    $aaa = $db->Execute($aaa_query);
    while (!$aaa->EOF) {
      echo $aaa->fields['bbb'];
      $aaa->MoveNext();
    }
    Last edited by tips007; 5 May 2013 at 10:22 PM.

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,704
    Plugin Contributions
    123

    Default Re: $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    If Method A gives you an issue, then perhaps the file is not truly integrated into Zen Cart. For example, have you included application_top.php?
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: $aaa = mysql_query($aaa_query) instead of while (!$aaa->EOF)

    Or you're using it from within a function or class, but haven't made the $db global, and thus it's unreachable due to the scope of your code.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 12
    Last Post: 27 Jul 2016, 12:20 AM
  2. v152 mysql_query
    By RodG in forum Bug Reports
    Replies: 4
    Last Post: 21 Dec 2013, 02:09 PM
  3. Replies: 9
    Last Post: 16 May 2007, 09:51 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