Jump to content

What is causing the error in this block of code?


torquate

Recommended Posts

As stated in the subject.

 

<?php

 

if(isset($_POST['submit']))

{

$query = "INSERT into players (name, address, city, state, zip, phone, gender, height, realheight, experience, speed, conditioning, athleticism, hands, commitment, throwing, claim, relationship, teamsport, email, beencaptain, willingcaptain, shirtsize, upa) ";

$query .= "VALUES (";

$query .= "'" . $_POST['name'] . "'";

$query .= ",'" . $_POST['address'] . "'";

$query .= ",'" . $_POST['city'] . "'";

$query .= ",'" . $_POST['state'] . "'";

$query .= ",'" . $_POST['zip'] . "'";

$query .= ",'" . $_POST['phone'] . "'";

$query .= ",'" . $_POST['gender'] . "'";

$heightreal = $_POST['feet'] * 12 + $_POST['inches'];

switch($_POST['gender'])

{

case 0:

if ($heightreal <= 64)

  $height = 1;

if ($heightreal > 64 && $height < 68)

  $height = 2;

if ($heightreal > 67 && $height < =71)

  $height = 3;

if ($heightreal > 71 && $height < =74)

  $height = 4;

if ($heightreal > 74 )

  $height = 5;

break;

case 1:

if ($heightreal <= 59)

  $height = 1;

if ($heightreal > 59 && $height < 64)

  $height = 2;

if ($heightreal > 63 && $height < =68)

  $height = 3;

if ($heightreal > 68 && $height < =70)

  $height = 4;

if ($heightreal > 70 )

  $height = 5;

break;

}

 

$query .= ",'" . $_POST['height'] . "'";

$query .= ",'" . $_POST['feet'] . "." . $_POST['inches'] . "'";

$query .= ",'" . $_POST['experience'] . "'";

$query .= ",'" . $_POST['speed'] . "'";

$query .= ",'" . $_POST['conditioning'] . "'";

$query .= ",'" . $_POST['athleticism'] . "'";

$query .= ",'" . $_POST['hands'] . "'";

$query .= ",'" . $_POST['commitment'] . "'";

$query .= ",'" . $_POST['throwing'] . "'";

 

if (strlen($_POST['claim'] > 0)

{

$query .= ",'" . $_POST['claim'] . " (" . $_POST['relationship'] . ")'";

}

else

{

$query .= ",''";

}

 

$query .= ",'" . $_POST['teamsport'] . "'";

$query .= ",'" . $_POST['email'] . "'";

$query .= ",'" . $_POST['beencaptain'] . "'";

$query .= ",'" . $_POST['willingcaptain'] . "'";

$query .= ",'" . $_POST['shirtsize'] . "'";

$query .= ",'" . $_POST['upa'] . "'";

 

$query .= ")";

 

$db->execute($query);

$id = mysql_insert_id();

}

 

 

?>

To turn on error reporting:

 

To turn on Error Reporting in PHP, this is what I use. You can set this anywhere in your PHP code, but it has to be above the error or else it will not work. This is the easiest way and will work in most hosting environments:

 

ini_set('display_errors',1);

error_reporting(E_ALL|E_STRICT);

 

or if you only want to see Warning Messages and not Notice Messages:

 

ini_set('display_errors',1);

error_reporting(E_ALL);

You must set the error_reporting/display_errors settings before your script is requested in order to show fatal parse errors. Since your script is never executed, the settings will never be changed when placed in your script. In addition to the problem that zeodragonzord posted (must be fixed in 4 places) there is a missing ) on one of the If() statements.

 

You need to set the error_reporting/display_errors settings in your master php.ini. You will save a TON of time. Stop and start your server to get any change made to the php.ini to take effect.

Sometimes in wordpress I experience if you put space after php closing ?>

 

//code ends
?>
////// THIS BLANK SPACE / LINE ////////////

 

Then page shows white screen which is popularly known White screen of Death.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.