Results 1 to 18 of 18
  1. #1
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Category display not working in dynamic script?
    The Fun to Collect folks offer a dynamic template which I've used for awhile. I even (with the author's permission) modified it to work with other Shareasale datafeeds.

    When trying to restore some websites I lost in a server crash, I suddenly realized the product display, generated by a file named category.php, wasn't working right.

    On the sample template at the FTC affiliate site, if you click on a link to display a category of products, you get 7 products displayed, then a "Next 7 Collectibles>>>" at the bottom of the page. Clicking on that, you get "<<<Previous 7 Collectibles Next 7 Collectibles>>>" at the bottom of each page until the products in that category have all been displayed. At the bottom of the last page of products in the category, you see:
    "<<<Previous 7 Collectibles" -- which takes you back screen by screen to the beginning of the products in that category.

    The problem is -- the category.php file in the ZIP file from FTC isn't working. It shows the first 7 products in the category, with "Next 7 Collectibles>>>" at the bottom -- but clicking on that "Next 7 Collectibles>>>" link causes NOTHING to happen, the browser just refreshes and continues to display the first 7 collectibles in the category. Won't go "forward" or "backward" in any way.

    Here's the code which I THINK creates the pagination, but I do not understand at all what's wrong. My PHP/MySQL knowledge is still very "puzzle it out as you go along," but I know it's probably something you gurus here can figure out:

    <?
    if(!$start){
    $start = 0;
    }
    if(!$limit){
    $limit = $perpage;
    }
    $end=($start+$limit);

    $sql = "SELECT * FROM products WHERE category='$category'";
    if(mysql_num_rows(mysql_query($sql)) < 1){
    echo "No Products In This Category";
    }

    $result = mysql_query("SELECT name,description,thumbimage,sku from products WHERE category='$category' ORDER by name ASC LIMIT $start, $limit") or die (mysql_error());
    while ($row = mysql_fetch_array($result))
    {
    include("product-display.inc");
    }
    $prv = ($start-$limit);
    $nxt = ($start+$limit);
    if($prv < 0){
    $previous = "";
    }else {
    $previous = "<a href=\"category.php?category=$cat2&start=$prv&limit=$limit\"><<< Previous $limit Collectibles</a>";
    }
    if(mysql_num_rows(mysql_query($sql)) < $nxt){
    $next = "";
    }else {
    $next = "<a href=\"category.php?category=$cat2&start=$nxt&limit=$limit\">Next $limit Collectibles >>></a>";
    }
    if(mysql_num_rows(mysql_query($sql)) > $limit){
    echo "
    <P><table border=0 bordercolor=#000000 align=center width=90% bgcolor=#ffffff cellpadding=3 cellspacing=0><TR>
    <TD align=center>
    <b>$previous</b> &nbsp; &nbsp; &nbsp; <b>$next</b>
    </font></TR></TD></table><P>
    ";
    }
    mysql_free_result($result);
    ?>

    Oh, yeah. I had a question about the template before and contacted the author of the script. He explained that it had been several years since he wrote it and he doesn't remember much about it, so I posted this here instead of trying to contact the author.

    Thanks for any suggestions. You can see how it's supposed to work at the FTC example template script online here:

    http://www.funtocollect.net/template/
    Generate more fake news.

  2. #2
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by writerguy
    The Fun to Collect folks offer a dynamic template which I've used for awhile. I even (with the author's permission) modified it to work with other Shareasale datafeeds.

    When trying to restore some websites I lost in a server crash, I suddenly realized the product display, generated by a file named category.php, wasn't working right.
    Have you checked the reply email I sent you, yet?

  3. #3
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Gary,
    I'd presume somewhere is a configuration file... maybe config.php?

    Be sure you've set the variable for $perpage as it doesn't look to be set in this file. This is the number of items per page that is being displayed and controls the $limit variable that is used in the query.
    Someday starts today
    Military Discounts

  4. #4
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Quote Originally Posted by knight01
    Gary,
    I'd presume somewhere is a configuration file... maybe config.php?

    Be sure you've set the variable for $perpage as it doesn't look to be set in this file. This is the number of items per page that is being displayed and controls the $limit variable that is used in the query.
    Yup, you're right. There's a config.inc file, and the number set there for the $perpage variable is set at 7.
    Generate more fake news.

  5. #5
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Gary,

    I just went to Geno's site:
    The newest FunToCollect dynamic template is up and available here.
    I downloaded the fun_to_collect.zip file, and uploaded all those files to one of my test directories as-is, I didn't even put my AID, and the templates were working just fine out of the box, and the pagination is working fine too.

    I know that you're not using the sripts with the same pagination format as the one in the original template, but if you do what we did before, I am sure you can figure out where is the little bug.

    I deleted all my files on a test directory, uploaded the all the files of the fun_to_collect.zip file, tested all the features and made sure they worked out of the box, then I deleted those files and put my own other files back the way I had it. And I did all that in less time that it has taken me to write this post.

    So the bug must be a missing: ; or ' or ", etc. but, maybe you missed one of those things, when you pasted the script.

  6. #6
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Just curious, not related to the pagination issue, does the config.inc file have your username and/or password in it?
    Someday starts today
    Military Discounts

  7. #7
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by knight01
    Just curious, not related to the pagination issue, does the config.inc file have your username and/or password in it?
    Are you talking to me?

    I guess you're, because I see no one else here... ~ Robert De Niro.

    I don't use the fun_to_collect.zip templates, I use my own version, so I do use my u-p +.

    With the fun_to_collect templates you don't have to, because you're calling the feed from outside.

  8. #8
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Mr. Sal, you or WriterGuy since you're familiar with the script. Wondering if the username/password is part of the config.inc file or if they are in another file.
    Someday starts today
    Military Discounts

  9. #9
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Ok, I went ahead and downloaded the script, funny thing, I wrote a script that does very much the same thing last year for myself.

    Gary, if you're using a version that has a config.inc file and not the new config.php, please download and start using the new version on the site. I know you'll lose your customization, but it's important to make this change.
    Someday starts today
    Military Discounts

  10. #10
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Wondering if the username/password is part of the config.inc file or if they are in another file.
    If you're using the fun_to_collect templates that Geno have available, you don't have to worry about the username/password on any of those files, you just have to make sure to modify this line: $affiliate_id = "Your-Aff-ID"; otherwise you will not get pay.

    If you're using your own config.inc file, then you must have this in there:

    $dbhost = "Site.com";
    $dbuser = "You";
    $dbpass = "Your-Pass";
    $dbname = "Your-DataBase-Name";
    $product_table = "Your-Table-Name";
    $affiliate_id = "Your-Aff-ID";

    As if the username/password can also be on another file, that is up to you, on how much security you want to have on the other files.

    Usually you just put all that critical info on the config.inc file, and then just call that file with:

    <?php include ('config.inc');
    //Your code here...
    ?>

    On any other file you need it.

  11. #11
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    If you are using your own modification of this or any script, you don't want to have a username/password in a .inc file, it is a security issue. Doing an include such as:
    PHP Code:
    <?php include ('config.inc');
    Does not eliminate the security concern. I learned the hard way a couple of years ago. It's important to keep username/password combinations in a .php (or other parsable ) file.
    Someday starts today
    Military Discounts

  12. #12
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by knight01
    If you are using your own modification of this or any script, you don't want to have a username/password in a .inc file, it is a security issue. Doing an include such as:
    PHP Code:
    <?php include ('config.inc');
    Does not eliminate the security concern. I learned the hard way a couple of years ago. It's important to keep username/password combinations in a .php (or other parsable ) file.
    I don't use any .inc

    The only reason I posted like that, was because:
    Wondering if the username/password is part of the config.inc file or if they are in another file.
    You asked with the .inc in there, so I renamed my reply to .inc just to make sure that we were talking about the same file.

    And you're right about the security thing.

  13. #13
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Gary,

    I just compared the category.php file that you have sent me, with other 5 of the same category.php files that I found on my HD with different dates, and after checking all 6 category.php files line by line, I don't see anything different.

    So your bug, is definitely on some other php file, on that directory!

    I quit!

  14. #14
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Mr. Sal,

    Thanks for that. You're probably right. Now I'll go see what's happening with other files.

    But on the non-customized, straight out of the "box" version I put up at on of my sites, with absolutely no modifications except my SAS user ID number -- it still fails to work as it should to do the pagination?
    Generate more fake news.

  15. #15
    AM Navigator Geno Prussakov's Avatar
    Join Date
    May 10th, 2005
    Location
    Washington D.C. Metro Area
    Posts
    11,798
    Gary,

    I've just sent you a PM. Please keep me posted on what you find out.

    Geno

  16. #16
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    A clue! A clue! I may have a clue!

    I just swapped email with a PHP/MySQL buddy who tells me he's having almost exactly the same problem with pagination on a similar script he wrote last summer. He changed hosts to a different server, and the script stopped working. He thinks it has something to do with the version of PHP or MySQL on his new host. The same script, he says, is continuing to work on the old server.

    So how would an updated version of PHP or MySQL have affected the script I'm asking about? I changed web hosts a few weeks ago after my previous host's server crashed. I have no idea of what versions of PHP/MySQL the old host used, and I don't know without looking it up about my new host. But is this the sort of thing which could be causing the pagination to fail?

    I honestly have no way of knowing and no memory for sure of whether the pagination was actually working on the old server. And all my sites are with the new host on their server now?

    Suggestions?
    Generate more fake news.

  17. #17
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Create a text file with only the following in it
    Code:
    php_flag register_globals on
    Upload it to your server via ftp in ascii format then rename it .htaccess (note the period at the beginning of the file name.)

    Check to see if you already have a .htaccess file, if you do then simply add that line as the last line of the file.
    Someday starts today
    Military Discounts

  18. #18
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    Quote Originally Posted by knight01
    Create a text file with only the following in it
    Code:
    php_flag register_globals on
    Upload it to your server via ftp in ascii format then rename it .htaccess (note the period at the beginning of the file name.)

    Check to see if you already have a .htaccess file, if you do then simply add that line as the last line of the file.
    Okay. It worked. Now the script works.

    Tell me the magic -- please, please, explain it to me.

    And thank you SO MUCH!
    Generate more fake news.

  19. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Creating a 3 column display with this PHP Script
    By bluewaves1 in forum Programming / Datafeeds / Tools
    Replies: 5
    Last Post: May 17th, 2007, 04:22 PM
  2. Category Script?
    By AlwaysLearning in forum Couponer's Corner
    Replies: 6
    Last Post: May 7th, 2003, 09:44 PM
  3. Replies: 10
    Last Post: February 25th, 2003, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •