Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP

Name: Alex 2010-04-17 0:42

    function randomAlbum($singleRandomArtist)
    {
        $artists = file('resources/artists.txt');
        $firstReturn = true;
        foreach ($artists as $singleArtist)
        {
            $randomArtist = explode("~", $singleArtist);
        if ($firstReturn == true)
        {
        echo $randomArtist[$singleRandomArtist]; *****
        $firstReturn = false;
        }
        else;
        }
    }
    function getRandomInt($min, $max)
    {
        $validRand = false;
        while ($validRand == false)
        {
            $random = rand($min, $max);
            if (($random % 3) == 0)
            {
                $validRand = true;
            }
            else;
        }
        return $random;
    }

The line with the *** next to it is giving me an undefined offset error. Any ideas why? Im rather new to php, so be nice!

Name: Anonymous 2010-04-17 0:48

Now you have two problems.

Name: Anonymous 2010-04-17 0:51

Now you have the problem of me coming and shoving my large foot up your ass you piece of shit

Name: Anonymous 2010-04-17 0:58

>>3
lol fag

Name: Anonymous 2010-04-17 1:02

Y'all think that's bad?

I saw the likes of this once (I'm not writing real PHP because then I'd have to kill myself):


// connect to db etc
// $match=0;
while(!$match) {
    // mysql "select * from $table;"
    // fetch random result from 0..$num_rows
    // if $row[$somefield] == 'thing_i_am_looking_for' { $match=1; }
}


This was how some dude randomized his results. The kicker is this: he had no matching data in the database and was bitching about the fact that his page always timed out.

Name: Alex 2010-04-17 1:09

I have no experience using a database, and its not a requirement of the assignment, but I need to get this rand() function to give me an integer back...

I do appreciate constructive feedback, thanks.

Name: Anonymous 2010-04-17 1:18

Abstract troll is insufficiently abstract.

Name: Anonymous 2010-04-17 2:18

( °‿‿°)

Name: Anonymous 2010-12-20 16:08

Name: Anonymous 2011-01-31 20:37

<-- check em dubz

Don't change these.
Name: Email:
Entire Thread Thread List