help with php please

Discussion in 'Web Design and Development' started by Cabbit, Dec 31, 2006.

  1. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #1
    hiya im having a problem with my php, i think its proberly the way i added it im not very good with php though i do try. can some one fix it please.

    Error:
    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/contact.php on line 46

    Code:
    <?php
    	$phpbb_root_path = './forum/';
    	define ('IN_PHPBB', true);
    	include_once ($phpbb_root_path . 'extension.inc');
    	include_once ($phpbb_root_path . 'common.' . $phpEx);
    	include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    	$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    	init_userprefs($userdata);
    	if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    	{
    	        $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    	        ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    	        if (!intval($CFG['posts_span_pages_offset']))
    	        {
    	                $CFG['posts_span_pages_offset'] = 0;
    	        }
    	}
    	$CFG['posts_limit'] = 8;
    	$CFG['posts_span_pages'] = true;
    	$latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>
    	"<?php
    //variables (change these)
    
    $youremail = "contact@jennifersplaygroup.co.uk";
    // your email address
    
    $subject = "Contact";
    // the subject of the email
    
    $thankyou = "thankyou.php";
    // thank you page
    
    // don't change anything else
    
    ;if($email == ""){
    ?>
    No email address added. Please go back.<br/>
    "<?php
    ;}elseif($name == ""){
    "?>
    No name added. Please go back.<br/>
    <?php
    ;}elseif($message == ""){
    "?>
    No message added. Please go back.<br/>
    "<?php
    ;}else{
    
    $msg = ereg_replace("\\\'", "'", $message);
    $msg = ereg_replace('\\\"', "\"", $msg);
    $message1 = "from: $name\nemail: $email\nmessage:\n$msg1";
    
    mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
    ?>
    <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
    "<?php
    }
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Jennifer's Playgroup</title>
    <link rel="stylesheet" href="stylesheet.css" type="text/css" />
    <style type="text/css">
    <!--
    .style1 {font-size: 120%}
    .style2 {font-size: 115%}
    -->
    
    </style></head>
    <body>
    <div id="container">
    
    <div id="masthead">
      <h1 id="siteName">Jennifer's Playgroup </h1>
      <div id="globalNav"> <a href="/index.php">Home</a> | <a href="/forum"></a><a href="/shop/catalog">Store</a> | <a href="forum.php">Forum</a> | <a href="/news_and_events.php">News & Events </a> | <a href="/support.php">Support</a>| <a href="/tips_and_tricks.php">Tips and Tricks  </a>| <a href="/storys.php">Story's </a>| <a href="/pictures.php">Pictures</a>| <a href="/videos.php">Videos </a> | <a href="/reviews.php">Reviews</a> | <a href="/links.php">Links</a> | <a href="http://jennifersplaygroup.co.uk/forum/login.php">Login</a> | <a href="forum/profile.php?mode=register&sid=f2f4b033b3abb9d56fe64d2a46dbe8a7">Register</a></div>
      <div> <h2 class="style1" id="pageName">Contact Us </h2> 
      </div>
    </div>
    <div id="headlines">
      <h3 class="style2">Headlines</h3>
      <p>Site Opening <a href="/headline_site_opening.php">full story...</a></p>
      <p>Site Goes PHP <a href="news_storys/site_php.php">full story...</a></p>
      <p>Story's Page Goes online <a href="headline_storys.php">full story...</a></p>
      <p> </p>
      <div id="advert"> <img src="/site_images/playgroup.jpg" alt="" width="200" height="176" /> Our <a href="/forum">Forum</a> is the place to be for bAby's, mummies and even little sissy's and bigger kids </div>
       <div id="advert"><!-- Search Google -->
    <center>
    <FORM method=GET action="http://www.google.com/search">
    <input type=hidden name=ie value=UTF-8>
    <input type=hidden name=oe value=UTF-8>
    <IMG SRC="http://www.google.com/logos/Logo_40wht.gif" 
    border="0" ALT="Google" align="absmiddle"></A>
    <INPUT TYPE=text name=q size=20 maxlength=255 value="">
    <INPUT type=submit name=btnG VALUE="Google Search">
    </FORM>
    </center>
    <!-- Search Google -->
    </div>
    </div>
    <!-- end masthead -->
    <div id="content">
      <div class="feature">
        <h3 align="left"><a href="/news.php"></a>Contact Us</h3>
        <form action="mail.php" method="post">
    Name 
      <input type="text" name="name"><br/>
    Email addess 
    <input type="text" name="email"><br/>
    Message<br/>
    <textarea name="message" cols="40" rows="5"></textarea><br/>
    <input type="submit" value="send"><br/>
    </form>
      </div>
    </div>
    <!-- end content -->
    <div id="navBar">
      <div id="sectionLinks">
        <div> <h3>Hot Forum Topics </h3> </div>
    <?php for ($i = 0; $i < count($latest); $i++) { ?>
    <a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $latest[$i]['topic_id']); ?>"><?php echo $latest[$i]['topic_title']; ?></a>
    <?php } ?>
      </div>
      <div class="relatedLinks">
        <h3>Soon to the Store </h3>
        <ul>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
        </ul>
      </div>
      <div class="relatedLinks">
        <h3>Top External Links </h3>
        <ul>
          <li><a href="http://cosyndry.com/">Cosyndry bAby Shop</a></li>
          <li><a href="http://www.hbenterprises.co.uk/Catalogue_GW.html">Precious Babywear Shop</a></li>
          <li><a href="http://aby.com/apm/home.php">Aby Dating Service</a></li>
          <li><a href="http://dailydiapers.com/">Daily Diapers Newspaper</a></li>
          <li><a href="http://www.happynappy.co.uk/html/pushchair.html">Happy Nappy Nursery</a></li>
    	<li><a href="http://www.babyjunior.co.uk/html/home.html">Baby Junior</a></li>
        </ul>
      </div>
    </div>
    <div id="siteInfo"><a href="/about.php">About Us</a> |<a href="/map.php"> Site Map</a>|<a href="/contact.php"> Contact Us</a> | ©2006 Jennifer's Playgroup </div>
    <br />
    </div>
    </body>
    </html>
    
     
  2. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #2
    A bit messy code to analyse completely (on New Years Eve ;)), but what are all those " good for...?

    PHP:
    ...
    ?>
    No email address added. Please go back.<br/>
    "<?php
    ;}elseif($name == ""){
    "?>
    No name added. Please go back.<br/>
    <?php
    ;}elseif(
    $message == ""){
    "
    ?>
    No message added. Please go back.<br/>
    "<?php
    ;}else{
    ...
    Those seem to mess up a bit...

    Also: Are you using a text editor with syntax colouring, like TextWrangler...? That is usually very helpful to discover small errors in - well - "syntaxing"... ;)
     
  3. xoreu macrumors member

    Joined:
    Nov 12, 2006
    #3
    I second Mitthrawnuruodo. By using the same method (pasting the code into a text editor with syntax highlighting, I found that removing the quotes at the beginning of lines 42 and 46 should free you of syntax errors.

    Also, in several places you have standalone semicolons inside if statements - I'm not sure whether that makes a difference, but I see no reason for having those.
     
  4. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #4
    Code:
    <?php
    	$phpbb_root_path = './forum/';
    	define ('IN_PHPBB', true);
    	include_once ($phpbb_root_path . 'extension.inc');
    	include_once ($phpbb_root_path . 'common.' . $phpEx);
    	include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    	$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    	init_userprefs($userdata);
    	if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    	{
    	        $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    	        ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    	        if (!intval($CFG['posts_span_pages_offset']))
    	        {
    	                $CFG['posts_span_pages_offset'] = 0;
    	        }
    	}
    	$CFG['posts_limit'] = 8;
    	$CFG['posts_span_pages'] = true;
    	$latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>
    <note above this is working code its only below bit thats broken i thinks.>
    <?php
    //variables (change these)
    $youremail = "contact@jennifersplaygroup.co.uk";
    // your email address
    $subject = "Contact";
    // the subject of the email
    $thankyou = "index.php";
    // thank you page
    // don't change anything else
    ;if($email == ""){
    ?>
    No email address added. Please go back.<br/>
    ?>
    No email address added. Please go back.<br/>
    "<?php
    ;}elseif($name == ""){
    "?>
    No name added. Please go back.<br/>
    <?php
    ;}elseif($message == ""){
    ?>
    No message added. Please go back.<br/>
    <?php
    ;}else{
    $msg = ereg_replace("\\\'", "'", $message);
    $msg = ereg_replace('\\\"', "\"", $msg);
    $message1 = "from: $name\nemail: $email\nmessage:\n$msg1";
    mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
    ?>
    <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
    "<?php
    }
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    these are the changes i made so far, still not working :(
    says Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/contact.php on line 48
     
  5. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #5
    Seems like it's the same problem. Are you using a text editor with syntax colouring?

    Also, it would be better if you use the php tags, and not the regular code tags when posting your code... :)
     
  6. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #6
    im useing a program called textedit, i have no idea about php i get along fine with things like css and html but php is a stumbling block. Any php i use i just copy and paste form guide sites but they were no help with this one. :( i just want it to work
     
  7. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #7
    Use TextWrangler, my favorite, or perhaps Taco HTML Edit instead of TextEdit, as mentioned above: syntax colouring makes php coding much easier... :)

    Also: Try getting rid of more of those " at the beginning of lines (where do they come from in the first place?). When you get STRING related problems, they (or their "little cousin" ') are usually the culprit:

    PHP:
    No email address added. Please go back.<br/>
    "<?php
    ;}elseif($name == ""){
    "?>
    No name added. Please go back.<br/>
    PHP:
    <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
    "<?php
    }
     
  8. web_god61 macrumors regular

    web_god61

    Joined:
    May 14, 2004
    #8
    instead of breaking the document everywhere with ?> and <?php, use echo "";

    heres a quick fix up
    PHP:
    <?php

    //cont......
        
    $latest phpbb_fetch_posts(nullPOSTS_FETCH_LAST);
    echo 
    "<note above this is working code its only below bit thats broken i thinks.>";

    //variables (change these)
    $youremail "contact@jennifersplaygroup.co.uk";
    // your email address
    $subject "Contact";
    // the subject of the email
    $thankyou "index.php";
    // thank you page
    // don't change anything else

    if($email == ""){ echo "No email address added. Please go back.<br/>";

    }elseif(
    $name == ""){ echo "No name added. Please go back.<br/>";

    }elseif(
    $message == ""){ echo "No message added. Please go back.<br/>";

    }else{

    $msg ereg_replace("\\\'""'"$message);
    $msg ereg_replace('\\\"'"\""$msg);
    $message1 "from: $name\nemail: $email\nmessage:\n$msg1";
    mail($youremail$subject$msg"From: $email\r\nReply-to: $email\r\n");
    ?>

    <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">

    <?php
    }
    ?>

    <html xmlns="http://www.w3.org/1999/xhtml">
    i dont know what that last meta http line is about, so i left it, didnt look at the top of the document.
     
  9. 4np macrumors 6502a

    4np

    Joined:
    Feb 23, 2005
    Location:
    The Netherlands
    #9
    yuck; messy php code :S If you want to use PHP more often have a look at the smarty templating engine for seperating logic from display....
     

Share This Page