Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

I can't find the error - can you?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

I can't find the error - can you?

Postby Volterra » Sat Jun 28, 2003 6:43 pm

I can't find the bug in this - I get:
Parse error: parse error in /home/a/annim/www/recommend.php on line 259

Code: Select all
<?   
/************* PHPRecommend v 1.3 ***************/ 
/************************************************/ 
/*  written by A. Gianotto - 3/28/2000          */ 
/*  To find out if this is the latest version   */ 
/*  of this script, email snipe@snipe.net, or   */ 
/*  visit http://www.snipe.net                  */ 
/************************************************/ 
/************************************************/ 

// Change the variable below to "no" if you do not wish to write
// the data to a text log
$logging="yes";

// Enter the website administrators email address here
$adminaddress = "webmaster@annimac.com.au"; 

// Enter the company name or site name here
$sitename = "annimac.com.au"; 

// Enter the address of your website here
$siteaddress ="http://www.annimac.com.au"; 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Recommend this Site</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
IF ($action=="") {
?>
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td colspan="3"><a name="top"></a>
     <img src="assets/images/homepage.jpg" width="600" height="146" alt="homepage" />
   </td>
  </tr>
  <tr>
    <td  colspan="3" class="content">
     <div id="nav" style="position:relative; left:0px; top:0px; width:130px; z-index:3">
        <p><img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="index.php"><span class="current">Home</span></a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="profile.php">Profile</a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="vision.php">Vision</a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" />Services<br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="presenting.php">Presentations</a><br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="coaching.php">Coaching</a><br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="studies.php">Future Studies</a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" />Publications<br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="trendsletter.php">Trendsletter</a><br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="http://www.annimac.com.au/trendsletter/archive.php?id=1">Archived Tletters</a><br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="articles.php">Articles by<span class="hdr2">  Annimac</span></a><br />
          <img src="assets/images/arrow_right_ss.gif" width="12" height="12" alt="" /><a class="hdr1" href="reference.php">Articles on<span class="hdr2"> Annimac</span></a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="search.php">Search</a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="links.php">Links</a><br />
          <img src="assets/images/shim.gif" width="1" height="18" alt="" /><a class="hdr1" href="contact.php">Contact</a><br />
        </p>
      </div>     
  <!-- web2printer:start -->
  <? 
$referer = getenv("HTTP_REFERER");   
print "<p><B>$referer</B><br /><br /></p>";
?>
<p>To send the URL of this page and a brief message to friends who might like
  it, just fill out the form below.<br /><br />
  <B>NOTE:</B> We only request your name and email address so that the person
  you are recommending the page to knows that you wanted them to see it, and that
  it is not junk mail. All fields marked with an asterisk (*) are required. You
  must enter at least one friend's name and email.</p>
<br />
<FORM METHOD=POST ACTION="<? echo "../$PHP_SELF"; ?>">
  <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3">
    <TR>
      <TD VALIGN="TOP">Your Name*:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="yname"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Your Email*:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="yemail"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">&</TD>
      <TD VALIGN="TOP">&</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #1 Name*:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="fname[1]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #1 Email*:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="femail[1]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" height="5">&</TD>
      <TD VALIGN="TOP" height="5">&</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #2 Name:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="fname[2]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #2 Email:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="femail[2]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" height="5">&</TD>
      <TD VALIGN="TOP" height="5">&</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #3 Name:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="fname[3]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #3 Email:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="femail[3]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" height="5">&</TD>
      <TD VALIGN="TOP" height="5">&</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #4 Name:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="fname[4]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP">Friend #4 Email:</TD>
      <TD VALIGN="TOP"><INPUT TYPE="text" NAME="femail[4]"></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" COLSPAN="2">&</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" COLSPAN="2">Additional Comments:</TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" COLSPAN="2"><textarea NAME="comments" rows="3" cols="45"></TEXTAREA></TD>
    </TR>
    <TR>
      <TD VALIGN="TOP" COLSPAN="2">
        <INPUT TYPE="hidden" NAME="url" VALUE="<? echo "$referer"; ?>">
        <INPUT TYPE="submit" NAME="action" VALUE="Send">
      </TD>
    </TR>
  </TABLE>
</FORM>
<br />
<? 

} ELSEIF ($action="Send") { 
    if (($yname=="") || ($fname=="")  || ($femail=="")|| ($yemail==""))  {
      print "Please use your back button and complete all of the required form fields, then resubmit.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
   } else {
        print "Your recmmendation to the following people has been sent:<br /><br /> ";
            // cycle through the email addresses and names
        $items="5";
        $tally="";
        for ($numitems=0; $numitems < $items; $numitems++) {
              if (($fname[$numitems]!="") && ($femail[$numitems]!=""))  {
                mail("$femail[$numitems]","$yname went to $sitename and recommended you check this out","$fname[$numitems] \n\n $yname stopped by $sitename and thought you would find the following URL of interest:\n \nURL: $url \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThank you! \n$sitename \n$adminaddress \n$siteaddress","FROM:$yemail"); 

            // NEW IN VERSION 1.2 - LOGGING TO A TEXT FILE - 7/31/00
            // this writes the url, comments, and email address
            // to a text database so you can easily track which
            // pages are being recommended most often

            // Be sure to upload the blank text file that the
            // data will write to.  In this case, we named it url-log.txt
            // If you name your blank file url-log.txt, no changes are needed here.
            // If you decide to use a different filename, you must change the
            // variable below.
                 
                IF ($logging=="yes") {
                   $filename="url-log.txt"; 
                      // Nothing needs ot be changed here
                   $fl=fopen($filename,"a+"); 
                   // sets the pipe delimiters
                   fwrite($fl,"'$url'|'$femail[$numitems]'|'$yemail'|'$comments'\n"); 
                   fclose($fl); 
                }
              $tally.="$fname[$numitems], ";
              }
         }

?>
      <P>Your message has been sent to <?php echo "$tally"; ?></p>
<!-- web2printer:end -->
     <p><B><A HREF="javascript:history.go(-2)">GO BACK</A></B><br /><br /></p>
     <p align="right"><a href="web2printer.php?img=0&tgs=1&lnk=0&style=mystyle.css&refer=<? echo $PHP_SELF ?>" target="_blank "><img src="assets/images/print.gif" width="13" height="13" alt="print" />printer friendly version</a></p>
    </td>
  </tr>
  <tr>
    <td class="footer" width="461">
        <a class="footer" href="index.php">Home</a>
      | <a class="footer" href="profile.php">Profile</a> | <a class="footer" href="vision.php">Vision</a> | <a class="footer" href="services.php">Services</a>
      | <a class="footer" href="trendsletter.php">FutureTrends</a> | <a class="footer" href="contact.php">Contact</a> | <a class="footer" href="disclaimer.php">Disclaimer</a>
      | <a class="footer" href="disclaimer.php#Information">Use of Info</a> | <a class="footer" href="disclaimer.php#Privacy">Privacy</a>
      <a href="http://www.mycgiscripts.com"></a><img src="assets/images/shim.gif" alt="" width="24" height="12" /><br />
      & Annimac Consultants :: updated <!-- #BeginDate format:En2 -->29-Jun-2003<!-- #EndDate -->
      :: <a class="footer" href="mailto:webmaster@annimac.com.au">webmaster</a>
      :: <a class="footer" href="recommend.php">Recommend this site</a><?php $table="ez_logezboo"; include ("/home/a/annim/www/secure/ezwebstats/write_logs.php"); ?>
    </td>
   <td width="113" class="footer"><a href="http://validator.w3.org/check/referer"><img src="assets/images/shim.gif" alt="" width="5" height="10" /></a><img src="assets/images/shim.gif" alt="" width="5" height="10" /></td>
    <td width="26" class="footer"><a href="http://www.icra.org/labelv02.html"><img src="assets/images/i26x25blk.gif" alt="" width="26" height="25" border="0" align="top" /></a>
  </td></tr>
</table>
</body>
</html>
[/code]
Volterra
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jun 28, 2003 6:35 pm

Postby pootergeist » Sun Jun 29, 2003 2:40 am

} ELSEIF ($action="Send") {

= is an assignment operator
== is a conditional
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

I've made the change but receive the same error

Postby Volterra » Sun Jun 29, 2003 2:47 am

What next my friend?
Volterra
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jun 28, 2003 6:35 pm

Postby Joel » Mon Jun 30, 2003 8:25 pm

The script wouldn't open at first because of an unexpected end, it took 2 or 3 curly braces at the end to end all the if statements to get the page running, but then it did run. Maybe you just havent ended your ifs properly?

When I ran this script, i got an error for undefined variable of action and tally, the action just needed an @ to suppress the error, instead of...

Code: Select all
If (!@$action)


instead of
Code: Select all
if ($action=="")
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron