2 Replies - 1224 Views - Last Post: 21 November 2007 - 11:01 AM Rate Topic: -----

#1 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

How I love it when PHP stops executing on me.

Posted 20 November 2007 - 04:59 PM

I've decided to get somewhat serious about coding something, because to this day I have not yet put something together that actually is fully functional. Right when I decided to start something, PHP craps out on me. But then again, I must be the one responsible.

Here is the codez.

<?PHP

// If session is unset, stop execution @ now.
if (!$_SESSION || isset($_POST['error']) || isset($_GET['error']))
{ exit(); }

// All error messages are stored in this string
$GLOBALS['errormsg'];

// Checks the length of an element and adds a message if 
function lencheck($field,$value,$len)
{
	if (strlen($value) > $len)
	{ 
		$GLOBALS['errormsg'] .= "".$field." is too long.\n"; 
		$GLOBALS['error'] = 1;
	}
}

// Spot Name
lencheck("Spot name", $_POST['s_spot_name'], 100);
$s_spot_name = htmlspecialchar(stripslashes($_POST['s_spot_name']));

// Interest: Skate
lencheck("Interest: Skate", $_POST['s_spot_skate'], 1);
$s_spot_skate = htmlspecialchar(stripslashes($_POST['s_spot_skate']));

// Interest: BMX
lencheck("Spot name", $_POST['s_spot_bmx'], 1);
$s_spot_bmx = htmlspecialchar(stripslashes($_POST['s_spot_bmx']));

// Interest: Inline
lencheck("Spot name", $_POST['s_spot_inline'], 1);
$s_spot_inline = htmlspecialchar(stripslashes($_POST['s_spot_inline']));

// Test if at least on of the three above are set

if (($s_spot_skate+$s_spot_bmx+$s_spot_inline) == 0)
	{$error = 1; $errormsg .= "You have not set any spot interest.\n";}

// Spot Type
if ($_POST['s_spot_type'] == "INVALID" || !isset($_POST['s_spot_type']))
{$error = 1; $errormsg.= "Spot type is invalid. \n";}
$s_spot_type = htmlspecialchar(stripslashes($_POST['s_spot_type']));

echo $GLOBALS['errormsg'];
echo "lol?";
?>


It's pretty darn simple. In the beggining, on first run I had some parse errors here and there, which I solved, but now I can't even get the last line to echo properly, looks like the execution just stops. On something as simple as this. I'm a noob. :v:

Anybody have an idea?

Is This A Good Question/Topic? 0
  • +

Replies To: How I love it when PHP stops executing on me.

#2 nav33n  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 02-October 07

Re: How I love it when PHP stops executing on me.

Posted 20 November 2007 - 10:50 PM

1. Change htmlspecialchar to htmlspecialchars.
2. Check if the session is being set. print_r($_SESSION) might help.

Hope that helps. Cheers.
Was This Post Helpful? 0
  • +
  • -

#3 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: How I love it when PHP stops executing on me.

Posted 21 November 2007 - 11:01 AM

Do you have error reporting turned and set to E_STRICT or E_ALL on at the .htaccess level? If not, that may help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1