953,986 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Create a PHP Script Game

Here's how this one works. I'll start by posting one line of PHP script. The next person to post will add another line and copy the script into their post. You will simply add a line of PHP code to the script everyone wrote above you. Also don't forget to use CODE tags and try to write your line based on the code in the post above you.
The first line:

session_start();
FlashCreations
Posting Whiz
395 posts since Sep 2008
Reputation Points: 47
Solved Threads: 47
 
exit("I'm mean.");

:P

MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
 

Here's how this one works. I'll start by posting one line of PHP script. The next person to post will add another line and copy the script into their post. You will simply add a line of PHP code to the script everyone wrote above you. Also don't forget to use CODE tags and try to write your line based on the code in the post above you. The first line:

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you." ?>


is that how the game goes?

tiger86
Posting Pro
548 posts since Feb 2008
Reputation Points: 48
Solved Threads: 11
 

Sure. Everyone just adds a line...but after the second post, there really wasn't anything that could be done....but we can ignore that post:
[code=PHP]
<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk += " I'm a slug...\n";
?>

FlashCreations
Posting Whiz
395 posts since Sep 2008
Reputation Points: 47
Solved Threads: 47
 

I have a few lines.

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

Not that they do much.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 
<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
mysql_query("SELECT id WHERE slug='{$slugtalk}'");
FlashCreations
Posting Whiz
395 posts since Sep 2008
Reputation Points: 47
Solved Threads: 47
 
<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
mysql_query("SELECT id WHERE slug='{$slugtalk}'");


OOPS - Fatal error, better fix it:

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
mysql_query("SELECT id FROM `table` WHERE slug='".mysql_real_escape_string($slugtalk)."'");
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Alright:

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
$res = mysql_query("SELECT id FROM `table` WHERE slug='".mysql_real_escape_string($slugtalk)."'");
$results = new array();
while($arr = mysql_fetch_array($res))
{
  $results[] = (int)$arr['id']+count($results);
}
FlashCreations
Posting Whiz
395 posts since Sep 2008
Reputation Points: 47
Solved Threads: 47
 

Got a few more lines

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
$res = mysql_query("SELECT id FROM `table` WHERE slug='".mysql_real_escape_string($slugtalk)."'");
$results = new array();
while($arr = mysql_fetch_array($res))
{
  $results[] = (int)$arr['id']+count($results);
  $results[((int)$arr['id']+count($results))]=true;
}
if (isset($results[$_GET['i']])) {
die('You won. <a href="index.php">Click here</a> to play again.');
} else if (isset($_GET['i']) && !empty($_GET['i'])) {
die('You lost mate. <a href="index.php">Click here</a> to loose again.');
} else {
echo "\n<p>".'<form method="get">Enter a number in the box below';
echo '<input type="text" name="i">';
echo '<input type="submit" value="Guess the number"></form>';
}
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You