O
oceanbluez

  • Oct 18, 2009
  • Joined Oct 5, 2009
  • Thanks so much for pointing that out! I looked at it for so long that I was missing the obvious! It now works!

    • I am creating an RSVP form that is supposed to submit information to sendrsvp.php.

      When I click on submit, I am getting the following errors:

      Parse error: syntax error, unexpected '[', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\Chapter.06\Projects\SendRSVP.php on line 25

      I have checked everything over again to the point where I can't find any errors.

      Can someone please proof my code and let me know if you find anything? The error states unexpected '[' but all my '[' are paired up.

      Code for rsvp.html

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>RSVP</title>
      <meta http-equiv="content-type"
      content="texthtml; charset=iso-8859-1" />
      </head>
      <body>
      <h1>Invitation</h1>
      <p>You are cordially invited to attend the celebration of the 
      Anderson's 50th wedding on October 15 at 8:00 p.m.</p>
      <form action="SendRSVP.php" method ="get">
      <h2>RSVP</h2>
      <p>Name &nbsp; <input type="text" name="name" size="50" /></p>
      <p><input type="radio" name="attendance" value="yes" />I will
      attend &nbsp; <input type="radio" name="attendance" />I will
      NOT attend &nbsp;</p>
      <p>Number of guests besides myself &nbsp; <input type="text" name="guests"  /></p>
      <p><input type="submit" value="Send RSVP" /><input type="reset" /></p></form>
      <p><a href="attending.php">See Who's Attending</a><br />
      <a href="notattending.php">See Who's Not Attending</a></p>
      </body>
      </html>
      
      

      Code for sendrsvp.php

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>RSVP</title>
      <meta http-equiv="content-type"
      content="texthtml; charset=iso-8859-1" />
      </head>
      <body>
      <?php
      
      if (empty($_GET['name']) || !isset($_GET['attendance']))
      	echo "<p>You must enter your name and specify whether you 
      		  will attend!  Click your browser's Back button to
      		  return to the RSVP form.</p>";
      else if ($_GET['attendance'] == "yes"
      	&& !is_numeric(&_GET['guests']))
      	echo "<p>Please specify the number of guests who will 
      	accompany you!  Click on your browser's Back button to 
      	return to the RSVP form.</p>";
      else
      {
      	if ($_GET['attendance'] == "yes")
      	{
      		$YesFile = "attending.txt";
      		if (file_put_contents($YesFile, addslashes($_GET['name'])
      		. ", " . $_GET['guests'] . "\n", FILE_APPEND))
      			echo "<p>Thanks for RSVPing!  We're looking forward
      				  to seeing you!</p>;
      		else
      			echo "<p>Cannot save to the $YesFile file.</p>";
      	}
      	if ($_GET['attendance'] == "no")
      	{
      		$NoFile = "notattending.txt";
      		if (file_put_contents($NoFile, addslashes($_GET['name'])
      		.  "\n", FILE_APPEND))
      			echo "<p>Thanks for RSVPing!  Sorry you can't
      			make it!</p>;
      		else
      			echo "<p>Cannot save to the $NoFile file.</p>";
      	}
      }
      ?>
      </body>
      </html>
      

      I am new at php so your assistance would be greatly appreciated!

      • I am very new to PHP. Right now we are working with functions and control structures. I have an assignment where I have to calculate earnings based on wage, hours, and potential overtime over 40 hours at 1.5.

        There are no examples in my text at this point that I can follow from for direction and at this point I am going blind.

        Can someone please provide assistance or direction on what I should be doing? As of now, all I am getting are errors.

        paycheck.html code:

        !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Paycheck Calculator</title>
        <meta http-equiv="Content-Type"
        	content="text/html; charset=iso-8859-1" />
        </head>
        <body>
        	<table>
            <tr>
            </tr>
            <tr>
                <td><h1>Paycheck Calculator</h1></td>
            </tr>
            <tr>
        
        
        </tr>
        </table>
        <hr />
        
        <form method="get" action="Paycheck.php">
            <p>Hours worked:
            <input type="text" name="hours" id="hours" />
            </p>
            <p>Employee wage:
            <input type="text" name="wage" id="wage" /><br /><br />
            <input type="submit" />
            </p>
        
        </form>
        </body>
        </html>
        

        paycheck.php code:

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Paycheck Results</title>
        <meta http-equiv="Content-Type"
        	content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="php_styles.css" type="text/css" />
        </head>
        <body>
        <h1>Paycheck Calculations</h1>
        <?php
        
        $hoursWorked = $_GET["hours"];
        $wages = $_GET["wage"];
        $x = $hoursWorked;
        $y = $wages;
        $z = $pay;
        
        if ($x is <= 40){
        $submit = ("$z = $x * $y")
        echo "Your Paycheck is: $payCheck";
        }
        
        if ($x is > 40){
        $submit = ("$z = ($x *$y) + (($x - 40) * $y * 1.5")
        echo "Your Paycheck is: $payCheck";
        }
        
        ?>
        </body>
        </html>
        

        Any assistance would be greatly appreciated.

        • I am very new to PHP. Right now we are working with functions and control structures. I have an assignment where I have to calculate earnings based on wage, hours, and potential overtime over 40 hours at 1.5.

          There are no examples in my text at this point that I can follow from for direction and at this point I am going blind.

          Can someone please provide assistance or direction on what I should be doing? As of now, all I am getting are errors.

          paycheck.html code:

          !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <title>Paycheck Calculator</title>
          <meta http-equiv="Content-Type"
          	content="text/html; charset=iso-8859-1" />
          </head>
          <body>
          	<table>
              <tr>
              </tr>
              <tr>
                  <td><h1>Paycheck Calculator</h1></td>
              </tr>
              <tr>
          
          
          </tr>
          </table>
          <hr />
          
          <form method="get" action="Paycheck.php">
              <p>Hours worked:
              <input type="text" name="hours" id="hours" />
              </p>
              <p>Employee wage:
              <input type="text" name="wage" id="wage" /><br /><br />
              <input type="submit" />
              </p>
          
          </form>
          </body>
          </html>
          

          paycheck.php code:

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <title>Paycheck Results</title>
          <meta http-equiv="Content-Type"
          	content="text/html; charset=iso-8859-1" />
          <link rel="stylesheet" href="php_styles.css" type="text/css" />
          </head>
          <body>
          <h1>Paycheck Calculations</h1>
          <?php
          /* Performed by Karan MacDonald
             Performed on October 4, 2009
             Introduction to understanding variable scopes 
             using Paycheck.html and Paycheck.php
          */
          $hoursWorked = $_GET["hours"];
          $wages = $_GET["wage"];
          $x = $hoursWorked;
          $y = $wages;
          $z = $pay;
          
          if ($x is <= 40){
          $submit = ("$z = $x * $y")
          echo "Your Paycheck is: $payCheck";
          }
          
          if ($x is > 40){
          $submit = ("$z = ($x *$y) + (($x - 40) * $y * 1.5")
          echo "Your Paycheck is: $payCheck";
          }
          
          ?>
          </body>
          </html>
          

          Any assistance would be greatly appreciated.