Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back a page or two to re-sync the thread and this will then show latest posts. Thanks, Mike.

php code problem..

  • 10-11-2008 4:35pm
    #1
    Registered Users Posts: 346 ✭✭


    Hey boardies!

    I am getting the following error message when I complete and submit my HTML form

    Parse error: syntax error, unexpected T_STRING in line 1

    [/B]the form actually works and the info is delivered to email, but can anyone help me spot what the problem is? Code below

    <?php
    $toEmail = "shane@email.ie";
    $subject = "Call-Back Required";
    $name = $_REQUEST;
    $fromEmail = $_REQUEST;
    $mobile = $_REQUEST ;
    $message = "\n Name: ".$_GET["name"]."\n Email: ".$_GET["email"]."\n Mobile: ".$_GET["mobile"]."\n\n";
    mail( $toEmail, $subject, $message );
    include('thankyou.htm');
    ?>


Comments

  • Closed Accounts Posts: 230 ✭✭danindublin


    I would say its the dot in line one, maybe try single quotes? (*I am not a php developer - just looks like its the problem*)


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Can we see the full code for the thankyou.htm file? It seems to me from what you've said that it is the line include('thankyou.htm'); that is throwing the error.

    And you should probably just use single quotes instead of a mixture of the too.


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    Evil Phil wrote: »
    Can we see the full code for the thankyou.htm file? It seems to me from what you've said that it is the line include('thankyou.htm'); that is throwing the error.

    And you should probably just use single quotes instead of a mixture of the too.
    If "thankyou.htm" is actually a HTML page then that's why the error is being thrown (can't just include HTML pages in PHP code).

    And more conformity with the quotes would also be good practice :)


  • Registered Users Posts: 346 ✭✭deepriver


    thankyou.htm code Phil


    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    <meta http-equiv="Cache-Control" content="public"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>thank you page</title></head>
    <body>
    <div id="branding">
    <div align="center"><img src="images/banner_200.jpg" alt="" width="200" height="34" /></div>
    </div>
    />Thank you for registering you interest, we will contact you shortly</p>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Evil Phil wrote: »
    Can we see the full code for the thankyou.htm file? It seems to me from what you've said that it is the line include('thankyou.htm'); that is throwing the error.

    And you should probably just use single quotes instead of a mixture of the too.
    Yep but bare in mind the \n characters will not be expanded in string literals (single quotes).


  • Advertisement
  • Registered Users Posts: 346 ✭✭deepriver


    CuLT wrote: »
    If "thankyou.htm" is actually a HTML page then that's why the error is being thrown (can't just include HTML pages in PHP code).

    And more conformity with the quotes would also be good practice :)

    How do I get the php to return a html page? This code actually worked before, just when i moved it to another page in another directory it started going wrong


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    deepriver wrote: »
    How do I get the php to return a html page? This code actually worked before, just when i moved it to another page in another directory it started going wrong
    You could do all the sending an error processing , then if all ok do a
    [php]header('location: /subdir/thankyou.html');[/php] on top your page (before any output done) and it will display this page


  • Registered Users Posts: 346 ✭✭deepriver


    Webmonkey wrote: »
    You could do all the sending an error processing , then if all ok do a
    [php]header('location: /subdir/thankyou.html');[/php] on top your page (before any output done) and it will display this page

    it didnt like that, same errror message


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    What's the error. It must be in the PHP script you doing the processing so if that is the case.
    By the way, where you have include('thankyou.htm');, you'd put that line. really you should do more server side checks to ensure correct and sufficient details entered. You could simply just have your HTML page start under the closing PHP tag also, nothing wrong with that.


  • Registered Users Posts: 346 ✭✭deepriver


    Webmonkey wrote: »
    What's the error. It must be in the PHP script you doing the processing so if that is the case.
    By the way, where you have include('thankyou.htm');, you'd put that line. really you should do more server side checks to ensure correct and sufficient details entered. You could simply just have your HTML page start under the closing PHP tag also, nothing wrong with that.

    made that change.. put the include at bottom and got

    CGI Error

    The specified CGI application misbehaved by not returning a complete set of HTTP headers.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Eh? - Where is this script working, where the thank you page - surely not in the cgi-bin. You may have your server set up to interpret html files as Perl. :confused: Strange


  • Registered Users Posts: 346 ✭✭deepriver


    Webmonkey wrote: »
    What's the error. It must be in the PHP script you doing the processing so if that is the case.
    By the way, where you have include('thankyou.htm');, you'd put that line. really you should do more server side checks to ensure correct and sufficient details entered. You could simply just have your HTML page start under the closing PHP tag also, nothing wrong with that.

    the original error is

    Parse error: syntax error, unexpected T_STRING in D:\console\logondetails\webaddress.ie\page\thankyou.htm on line 1


  • Registered Users Posts: 346 ✭✭deepriver


    Webmonkey wrote: »
    Eh? - Where is this script working, where the thank you page - surely not in the cgi-bin. You may have your server set up to interpret html files as Perl. :confused: Strange

    my noggin is fried with this lol.. I should point out I am a very green developer!:O


  • Registered Users Posts: 346 ✭✭deepriver


    is there something wrong with my thankyou.htm page? maybe corrupted or something... as I mentioned, this code worked before on another site very recently, same web servers, copy and past job, updated the urls, form boxes where the same


    Parse error: syntax error, unexpected T_STRING in D:\console\logondetails\webaddress.ie\page\thankyou.htm on line 1


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Well htm should not be intepreted anyways. I think your whole server is set up incorrectly or wierdly. Just wait and see if others have opinions here.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I agree with webmonkey, it might be a config thing. How is the server setup to handle htm files? And what kind of webserver are you using?


  • Registered Users, Registered Users 2 Posts: 6,522 ✭✭✭daymobrew


    CuLT wrote: »
    If "thankyou.htm" is actually a HTML page then that's why the error is being thrown (can't just include HTML pages in PHP code)
    The docs for include seem to imply otherwise.
    When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.

    deepriver - what happens when you comment out the 'include' line? (might as well try to determine if this file is the issue).


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    Quick and dirty fix

    On the first line of thankyou.htm do this
    print <<< EOT

    And on the last line put

    EOT;

    The eot has to be at the start of the line. Otherwise a header re-direct will work, just give the file a html extention instead of a PHP one. It may be that php is not set up correctly on your computer and the xml at the top (the <? bit especially) is throwing it off.

    EDIT : Or just get rid of the xml decleration at the top.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    eob wrote:
    The eot has to be at the start of the line. Otherwise a header re-direct will work, just give the file a html extention instead of a PHP one. It may be that php is not set up correctly on your computer and the xml at the top (the <? bit especially) is throwing it off.

    This is a good point. Shorthand opening tags for PHP might be enabled so it gets intepreted. Your server is set up to intepret htm pages as PHP. What web server are you using? - In PHP.ini file you can change the short_open_tag true line to short_open_tag false.
    Ideally you should also edit the http.conf file in Apache to stop PHP from intpreting htm pages.


  • Registered Users Posts: 346 ✭✭deepriver


    yes apparently the first line of my thankyou.htm document was being interpreted as a php page / code... because it starts with a <?... got it sorted anyhow, so thanks for the responses, much appreciated


  • Advertisement
  • Subscribers Posts: 9,716 ✭✭✭CuLT


    daymobrew wrote: »
    The docs for include seem to imply otherwise.
    Hmm, can't believe I never came across something so fundamental before. Assumption is the mother of all f*ck ups as they say... Ta.


  • Registered Users Posts: 346 ✭✭deepriver


    coming from a non-tech background.. it seems a bit lame on dotmobi to recommend starting a xhtml page with <? if any interaction with php code is going to screw everything up...

    I got a fix on the php code side, but it could have been solved by reverting the html code back to the standard <!DOCTYPE html......


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Well it is very uncomon to set a webserver up to interpret htm pages as PHP. So usually it isn't a problem


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    deepriver wrote: »
    coming from a non-tech background.. it seems a bit lame on dotmobi to recommend starting a xhtml page with <? if any interaction with php code is going to screw everything up...

    I got a fix on the php code side, but it could have been solved by reverting the html code back to the standard <!DOCTYPE html......


    Mostly it's a bit lame to have short tags switched on.
    1. It encourages lazy code
    2. It interferes with XML


Advertisement