+ Reply to Thread
Results 1 to 9 of 9

Thread: All In One Simple PHP Test Script Need Help

  1. #1
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Question All In One Simple PHP Test Script Need Help

    So I bought a PHP book that is giving me lessons to do and the one I just did was a "All in one" script" that instead of having a front end and back end script it just has it all in one file. Anyways I typed it all up and I am getting a error on line 29.
    Parse error: parse error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\allinone_form.php on line 29
    Anyways here is the code

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE>All-In-One</TITLE>
    </HEAD>
    <BODY>

    <?

    $form_block 
    "
    <FORM METHOD=\"POST\" ACTION=\"
    $_SERVER[PHP_SELF]\">

    <P><strong>Your Name:</strong><br>
    <INPUT type=\"text\" NAME=\"sender_name\" SIZE=30></P>

    <P><strong>Your E-Mail Address:</strong><br>
    <INPUT type=\"text\" NAME=\"sender_email\" SIZE=30></P>

    <P><strong>Message:</strong><br>
    <TEXTAREA NAME=\"message\" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></P>

    <INPUT type=\"hidden\" name=\"op\" value=\"ds\">

    <P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></P>

    </FORM>"
    ;

    if (
    $_POST[op] != "ds) {
        // They need to see the form
        echo "
    $form_block";
    } else if (
    $_POST[op} =="ds") {
        if (
    $_POST[sender_name] == "") {

    $name_err = "font color=red>Please enter your name!</font><br>;
    $send "no";

    if (
    $_POST[sender_email] == "") {
    $email_err "<font color=red>Please enter your e-mail address!</font><br>";
    $send "no";
    }

    if (
    $_POST[message] == "") {
        
    $message_err "<font color red>Please enter a message!</font><br>";
        
    $send "no";
    }

    if (
    $send != "no") {
        
    // it's ok to send!
    $to "dquigley@dollarstoriches.com";
    $subject "All-In-One Website Feedback";
    $mailheaders "From: My Web Site <dquigley@dollarstoriches.com> \n";
    $mailheaders .= "Reply-To: $_POST[sender_email]\n";
    $msg "E-MAIL SENT FROM WWW SITE\n";
    $msg .= "Sender's Name:   $_POST[sender_name]\n";
    $msg .= "Sender's E-Mail: $_POST[sender_email]\n";
    $msg .= "Message:        $_POST[message]\n\n";

    mail($to$subject$msg$mailheaders);

    echo 
    "<P>Mail has been sent!</P>";
    }

    else if (
    $send == "no") {

    echo 
    "$name_err";
    echo 
    "$email_err";
    echo 
    "$message_err";
    echo 
    "$form_block";
        }
    }

    ?>
    ?>

    </BODY>
    </HTML>

    Line 29 is
    PHP Code:
        echo "$form_block"
    Thanks for the help in advance, also please try to keep the help to error correction and not changing the script, this is just for learning, and Id like to do it BY THE BOOK so please, errors only.

  2. #2
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: All In One Simple PHP Test Script Need Help

    Line 27 should be

    if ($_POST[op] != "ds") {

    You forgot the closing quote.

  3. #3
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: All In One Simple PHP Test Script Need Help

    Yes thank you, I fixed that and a couple other errors that I found, now I am getting a error for line 34

    $send = "no";
    Edit:
    Nm fixed that one, now I got error on line 75
    </HTML>
    Last edited by dquigley; 12-13-2008 at 03:06 PM. Reason: Automerged Doublepost

  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: All In One Simple PHP Test Script Need Help

    well I see 2 end ?> php tags, while you only have one opening, not sure if that's the problem tho, I just saw that

  5. #5
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: All In One Simple PHP Test Script Need Help

    Oops I fixed that but that didnt fix anything, thanks


    Here is current script, I fixed lots of errors.

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE>All-In-One</TITLE>
    </HEAD>
    <BODY>

    <?

    $form_block 
    "
    <FORM METHOD=\"POST\" ACTION=\"
    $_SERVER[PHP_SELF]\">

    <P><strong>Your Name:</strong><br>
    <INPUT type=\"text\" NAME=\"sender_name\" SIZE=30></P>

    <P><strong>Your E-Mail Address:</strong><br>
    <INPUT type=\"text\" NAME=\"sender_email\" SIZE=30></P>

    <P><strong>Message:</strong><br>
    <TEXTAREA NAME=\"message\" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></P>

    <INPUT type=\"hidden\" name=\"op\" value=\"ds\">

    <P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></P>

    </FORM>"
    ;

    if (
    $_POST[op] != "ds") {
        
    // They need to see the form
        
    echo "$form_block";
    } else if (
    $_POST[op] == "ds") {
        if (
    $_POST[sender_name] == "") {

    $name_err "font color=red>Please enter your name!</font><br>";
    $send "no";

    if (
    $_POST[sender_email] == "") {
    $email_err "<font color=red>Please enter your e-mail address!</font><br>";
    $send "no";
    }

    if (
    $_POST[message] == "") {
        
    $message_err "<font color red>Please enter a message!</font><br>";
        
    $send "no";
    }

    if (
    $send != "no") {
        
    // it's ok to send!
    $to "dquigley@dollarstoriches.com";
    $subject "All-In-One Website Feedback";
    $mailheaders "From: My Web Site <dquigley@dollarstoriches.com> \n";
    $mailheaders .= "Reply-To: $_POST[sender_email]\n";
    $msg "E-MAIL SENT FROM WWW SITE\n";
    $msg .= "Sender's Name:   $_POST[sender_name]\n";
    $msg .= "Sender's E-Mail: $_POST[sender_email]\n";
    $msg .= "Message:        $_POST[message]\n\n";

    mail($to$subject$msg$mailheaders);

    echo 
    "<P>Mail has been sent!</P>";
    }

    else if (
    $send == "no") {

    echo 
    "$name_err";
    echo 
    "$email_err";
    echo 
    "$message_err";
    echo 
    "$form_block";
        }
    }

    ?>

    </BODY>
    </HTML>
    Last edited by dquigley; 12-13-2008 at 03:50 PM.

  6. #6
    TheMan177 is offline x10 Sophmore TheMan177 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    179

    Re: All In One Simple PHP Test Script Need Help

    This has not been closed:
    PHP Code:
    } else if ($_POST[op] == "ds") { 

  7. #7
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: All In One Simple PHP Test Script Need Help

    hmm could u be a bit more specific as where to put what, I tried to fix it with what u said and I think I did it wrong, thank you
    Edit:
    Ahh nm I fixed it thank you for ur help it works now u were all great.
    Last edited by dquigley; 12-13-2008 at 06:29 PM. Reason: Automerged Doublepost

  8. #8
    TheMan177 is offline x10 Sophmore TheMan177 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    179

    Re: All In One Simple PHP Test Script Need Help

    If you are having difficulty in identifing where brackets open and close, might I suggest a change to your indent style. Here's an example of what I'm talking about:

    PHP Code:
    <HTML>
        <HEAD>
            <TITLE>All-In-One</TITLE>
        </HEAD>
        <BODY>
    <?

    $form_block 

    <FORM METHOD=\"POST\" ACTION=\"
    $_SERVER[PHP_SELF]\"> 

    <P><strong>Your Name:</strong><br> 
    <INPUT type=\"text\" NAME=\"sender_name\" SIZE=30></P> 

    <P><strong>Your E-Mail Address:</strong><br> 
    <INPUT type=\"text\" NAME=\"sender_email\" SIZE=30></P> 

    <P><strong>Message:</strong><br> 
    <TEXTAREA NAME=\"message\" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></P> 

    <INPUT type=\"hidden\" name=\"op\" value=\"ds\"> 

    <P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></P> 

    </FORM>"
    ;

    if (
    $_POST[op] != "ds")
    {
        
    // They need to see the form
        
    echo "$form_block";
    }
    else if (
    $_POST[op] == "ds")
    {
        if (
    $_POST[sender_name] == "")
        {
            
    $name_err "font color=red>Please enter your name!</font><br>";
            
    $send "no";

            if (
    $_POST[sender_email] == "")
            {
                
    $email_err "<font color=red>Please enter your e-mail address!</font><br>";
                
    $send "no";
            }

            if (
    $_POST[message] == "")
            {
                
    $message_err "<font color red>Please enter a message!</font><br>";
                
    $send "no";
            }

            if (
    $send != "no")
            {
                
    // it's ok to send!
                
    $to "dquigley@dollarstoriches.com";
                
    $subject "All-In-One Website Feedback";
                
    $mailheaders "From: My Web Site <dquigley@dollarstoriches.com> \n";
                
    $mailheaders .= "Reply-To: $_POST[sender_email]\n";
                
    $msg "E-MAIL SENT FROM WWW SITE\n";
                
    $msg .= "Sender's Name:   $_POST[sender_name]\n";
                
    $msg .= "Sender's E-Mail: $_POST[sender_email]\n";
                
    $msg .= "Message:        $_POST[message]\n\n";

                
    mail($to$subject$msg$mailheaders);

                echo 
    "<P>Mail has been sent!</P>";
            }
            else if (
    $send == "no")
            {
                echo 
    "$name_err";
                echo 
    "$email_err";
                echo 
    "$message_err";
                echo 
    "$form_block";
            }
        }
    }
    ?>
        </BODY>
    </HTML>
    The opening and closing brackets always exist on the same indentation as one another, might help you identify problems like this a bit more.

  9. #9
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: All In One Simple PHP Test Script Need Help

    Ahh yes, I like that, I will try and do that from now on thank you again.

+ Reply to Thread

Similar Threads

  1. Problem With PHP Script
    By xevell in forum Programming Help
    Replies: 1
    Last Post: 07-23-2008, 03:41 AM
  2. PHP Versions & Resource Usage Script
    By Bryon in forum News and Announcements
    Replies: 11
    Last Post: 02-27-2008, 05:51 PM
  3. PHP Photo browser and x-fading slideshow script...
    By unmanaged in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 02-21-2008, 05:46 PM
  4. RSS to HTML PHP Script (FREE)
    By unmanaged in forum Scripts & 3rd Party Apps
    Replies: 6
    Last Post: 02-21-2008, 04:44 PM
  5. php script works elsewhere, not on x10
    By atomman in forum Programming Help
    Replies: 6
    Last Post: 01-10-2008, 08:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers