Hey, how's everyone doin'!

I've made a random link gen and it worls fine except for one thing

every so often it directs me to a blank page, no url, like a url wasn't even loaded.

it works about 95% of the time but this one little thing is buggin me to death.

could this be because I don't have enough links in the table to actually be random? I have about 5 test links in my table.
In the end about 200 links will be loaded, so I wanna get this straight before I do it.

give me a sec' and I'll post the script

Thanks
Derek

    After someone clicks the link they are led here and redirected to a url defined by the variable $cat in the url

    $result = mysql_query("SELECT url from galleries where cat='$cat' ORDER BY RAND()");

    while ($row = mysql_fetch_array($result))

    {

    header('Location: ' . $row['url']);

    }

    Again Thanks for any help
    Derek

      Well, dunno where you get $cat from in your query, but try adding a AND url IS NOT NULL to the query

        $cat comes from the url
        "gallery.php?cat=something"

        I know I'm supposed to use something like
        $cat = Get['cat']; or something like that

        but I forgot and it still works. Don't know why but hey I'm not complaining.

        I'll try your suggestion
        Thanks
        Derek

          It works because register_globals in On. Lots of discussion about that on here. Having that on makes security a bit lower, but will allow you to do that

            Sorry but it's still happening

            Thanks though

            anything else I could try

            I just tried using $_GET['cat']

            and it doesn't even work now,
            funny

              Well, ya know, this doesn't exactly seem random, considering you're passing the url....

              Maybe it's just not finding it? Try ejust echoing the result to the screen instead of redirecting.

                It does work, well like I said about 95% of the time.
                I am getting a random url out of the table and it is loading
                but like I said every so often it shows a blank page, like it never even got to the redirect script.

                Basically it's working like this:

                First page has a list of links of different catagories
                ex

                Catagory1
                gallery.php?cat=var1
                gallery.php?cat=var1
                gallery.php?cat=var1
                gallery.php?cat=var1

                Catagory2
                gallery.php?cat=var2
                gallery.php?cat=var2
                gallery.php?cat=var2
                gallery.php?cat=var2

                The reason I have a list of the same basic link is because I also have a random description script putting random general descriptions for each link. I hope that makes sense. 😃

                When someone clicks a link they are sent to a redirect script which pulls the variable from the url. Depending on the variable the surfer will be redirect to a random url in the same catagory as the variable.

                I could put this all in one file but I want to drop a cookie so the surfer doesn't go to the same url twice, that's where the redirect script comes in.

                The script you see here is the redirect script because I know the variable is passing since most of the time I do get redirected to a random url. But it's that "every so often" I want to fix

                I'll keep check things
                but if you have any more suggestions please share
                Thanks
                Derek

                  Write a Reply...