Hello,

While putting together a sticky form I got this error:

Parse error: parse error in C:\wamp\www\base_ball\insert_player.php on line 175

The problem is that this line of code does not exist. The script ends at line 174. Here are the bits of code I have altered:

<?php
if (isset($_POST['Insert'])){
$ln = $_POST['ln'];
$fn = $_POST['fn'];
$mi = $_POST['mi'];

...

$team = $_POST['team'];
$output_form = false;

if (empty($ln) || empty($fn) || empty($pcell)){
echo 'You forgot either the last name, first name, or player\'s cell. <br \>';
$output_form = true;
}
else
{
$query = "INSERT INTO player...

...

if ($output_form){
?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table cellspacing="0" cellpadding="0" width="100%"> 

...

<input type="Submit" value="Insert" name="Insert">
</form>
<?php
}
?>


<?php require("includes/footer.php"); ?>
<meta http-equiv="Refresh" content="1; url=add_thankyou.php">
Line 174 above ^^^

I'm not sure what to do when the parser picks up code that doesn't exist unless it is expecting something on the next line (175)?

There might be something in includes/footer.php that's doing it. As a side note a meta refresh tag goes in the head section, not the body.

Post the entirety of the code so I can at least run it through phplint to see if there are syntax errors :)

There might be something in includes/footer.php that's doing it. As a side note a meta refresh tag goes in the head section, not the body.

Post the entirety of the code so I can at least run it through phplint to see if there are syntax errors :)

Okay, but the code needs to be refactored!

I did not realize I was using a header. The goal of that line is to simply redirect the user to a page that echos "Record deleted". Is there an alternative I can use?

<?php require_once("includes/connection.php"); ?>
<?php include("includes/header.php"); ?>

<?php
if (isset($_POST['Insert'])){
$ln = $_POST['ln'];
$fn = $_POST['fn'];
$mi = $_POST['mi'];
$ad = $_POST['ad'];
$ci = $_POST['ci'];
$st = $_POST['st'];
$zi = $_POST['zi'];
$mn = $_POST['mn'];
$dn = $_POST['dn'];
$pcell = $_POST['pcell'];
$mcell = $_POST['mcell'];
$dcell = $_POST['dcell'];
$hnumber = $_POST['hnumber'];
$mwork = $_POST['mwork'];
$dwork = $_POST['dwork'];
$memail = $_POST['memail'];
$demail = $_POST['demail'];
$pemail = $_POST['pemail'];
$prefemail = $_POST['prefemail'];
$emerc = $_POST['emerc'];
$emercnumber = $_POST['emercnumber'];
$yrsp = $_POST['yrsp'];
$medc = $_POST['medc'];
$text = array('Yes','No');
$text = $_POST['text'];
$feet = $_POST['feet'];
$inches = $_POST['inches'];
$lbs = $_POST['lbs'];
$oz = $_POST['oz'];
$AoD = $_POST['AoD'];
$position = $_POST['position'];
$prefs = $_POST['prefs'];
$school = $_POST['school'];
$DoBMM = $_POST['DoBMM'];
$DoBDD = $_POST['DoBDD'];
$DoBYYYY = $_POST['DoBYYYY'];
$team = $_POST['team'];
$output_form = false;

if (empty($ln) || empty($fn) || empty($pcell)){
echo 'You forgot either the last name, first name, or player\'s cell. <br \>';
$output_form = true;
}
else{

$query = "INSERT INTO player (last_name, first_name, middle_initial, home_address, city, state, zip, mother, father,".
"player_cell, mom_cell, dad_cell, home_number, mom_work_number, dad_work_number, mom_email, dad_email, personal_email,".
"preferred_email, years_played, medical_conditions, emergency_contact_name, emergency_contact_phone, texting, as_of_date,".
"position_played, preferences, school, DoBMM, DoBDD, DoBYYYY, feet, inches, lbs, oz, team)".
"VALUES('$ln','$fn','$mi','$ad','$ci','$st','$zi','$mn','$dn','$pcell','$mcell','$dcell','$hnumber','$mwork','$dwork','$memail','$demail',".
"'$pemail','$prefemail','$yrsp','$medc','$emerc','$emercnumber','$text','$AoD','$position','$prefs','$school','$DoBMM','$DoBDD',".
"'$DoBYYYY','$feet','$inches','$lbs','$oz','$team')";

$result = mysql_query($query, $connection)
or die("Database query failed: " . mysql_error());
}
if ($output_form){
?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table cellspacing="0" cellpadding="0" width="100%"> 
  <tr>
    <th align="left" width="30%">Personal</th>
    <th align="left" width="30%">Contact</th>
    <th align="left" width="50%">Stats</th>
  </tr>
  <tr>
    <td valign="top">Last Name: <input type="text" name="ln" maxlength=30 size=30></td>
    <td valign="top">Player Cell: <input type="text" name="pcell" maxlength=10 size=10><br></td>
    <td valign="top">Years Played: <input type="text" name="yrsp" maxlength=2 size=2></td>
  </tr>
  <tr>
    <td valign="top">First Name: <input type="text" name="fn" maxlength=30 size=30></td>
    <td valign="top">Mom Cell: <input type="text" name="mcell" maxlength=10 size=10></td>
    <td valign="top">Height: <input type="text" name="feet" maxlength=5 size=4> ' <input type="text" name="inches" maxlength=2 size=2> "<br></td>
  </tr>
  <tr>
    <td valign="top">Middle Initial: <input type="text" name="mi" maxlength=1 size=1></td>
    <td valign="top">Dad Cell: <input type="text" name="dcell" maxlength=10 size=10></td>
    <td valign="top">Weight: <input type="text" name="lbs" maxlength=5 size=4> lbs <input type="text" name="oz" maxlength=2 size=2> oz</td>
  </tr>
  <tr>
    <td valign="top">Address: <input type="text" name="ad" maxlength=30 size=30></td>
    <td valign="top">Home Number: <input type="text" name="hnumber" maxlength=10 size=10></td>
    <td valign="top">Position Played: <input type="text" name="position" maxlength=30 size=30><br></td>
  </tr>
  <tr>
    <td valign="top">City: <input type="text" name="ci" maxlength=30 size=30></td>
    <td valign="top">Mom Work Number: <input type="text" name="mwork" maxlength=10 size=10></td>
    <td valign="top">DOB: <input type="text" name="DoBMM" maxlength=2 size=1> MM <input type="text" name="DoBDD" maxlength=2 size=1> DD <input type="text" name="DoBYYYY" maxlength=4 size=3> YYYY</td>
  </tr>
    <tr>
    <td valign="top">State: <input type="text" name="st" maxlength=2 size=2></td>
    <td valign="top">Dad Work Number: <input type="text" name="dwork" maxlength=10 size=10></td>
    <td valign="top">Team: <input type="text" name="team" maxlength=30 size=30></td>
      </tr>
      <tr>
    <td valign="top">Zip: <input type="text" name="zi" maxlength=5 size=5></td>
    <td valign="top">Emergency Contact Phone: <input type="text" name="emercnumber" maxlength=10 size=10></td>
    <td valign="top">As of Date: <input type="date" name="AoD" maxlength=30 size=30>
</td>
      </tr>
      <tr>
    <td valign="top">Mother: <input type="text" name="mn" maxlength=30 size=30></td>
    <td valign="top">Mom Email: <input type="text" name="memail" maxlength=30 size=30></td>
    <td valign="top">&nbsp</td>
      </tr>
  <tr>
    <td valign="top">Father: <input type="text" name="dn" maxlength=30 size=30></td>
    <td valign="top">Dad Email: <input type="text" name="demail" maxlength=30 size=30></td>
    <td valign="top">&nbsp</td>
  </tr>
    <tr>
    <td valign="top">&nbsp</td>
    <td valign="top">Personal Email: <input type="text" name="pemail" maxlength=30 size=30></td>
    <td valign="top">&nbsp</td>
  </tr>
      <tr>
    <td valign="top">&nbsp</td>
    <td valign="top">Preferred Email: <input type="text" name="prefemail" maxlength=30 size=30></td>
    <td valign="top">&nbsp</td>
  </tr>
            <tr>
    <td valign="top">&nbsp</td>
    <td valign="top">Texting: <br>
<INPUT type="radio" 
       value="Yes"
       name="text"
       checked> Yes<br>
<INPUT type="radio" 
       value="No"
       name="text"> No</td>
    <td valign="top">&nbsp</td>
  </tr>
                  <tr>
    <td valign="top">&nbsp</td>
    <td valign="top">Emergency Contact Name: <input type="text" name="emerc" maxlength=30 size=30></td>
    <td valign="top">&nbsp</td>
  </tr>
                        <tr>
    <td valign="top">&nbsp</td>
    <td valign="top">Emergency Contact Phone: <input type="text" name="emercnumber" maxlength=10 size=10></td>
    <td valign="top">&nbsp</td>
  </tr>
  </table>
<table>
    <tr>
    <th align="left" width="30%">Additional</th>
    <th align="left" width="30%">&nbsp</th>
    <th align="left" width="30%">&nbsp</th>
    </tr>
    <tr>
    <td valign="top">Medical Conditions:<br>
<TEXTAREA name="medc"  cols=30  rows=4>250 Characters</TEXTAREA></td>
    <td valign="top">Preferences:<br><TEXTAREA name="prefs"  cols=30  rows=4>250 Characters</TEXTAREA></td>
    <td valign="top">School:<br><TEXTAREA name="school"  cols=30  rows=4>90 Characters</TEXTAREA></td>
  </tr>
</table>
<br>
    <input type="Submit" value="Insert" name="Insert">
</form>
<?php
}
?>


<?php require("includes/footer.php"); ?>
<meta http-equiv="Refresh" content="1; url=add_thankyou.php">

You never end the first if so its waiting for the ending brace. And what I meant was that <meta> tags go in <head> in the document

Or use
header('Refresh: 1;url=yourpage')
to redirect

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.