10 Replies - 387 Views - Last Post: 11 February 2013 - 02:06 AM Rate Topic: -----

#1 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Can you Find my syntax error expecting ',' or ';' plea

Posted 10 February 2013 - 11:49 PM

This is driving me crazy trying to figure out what I am doing wrong with this form I am guessing something is not closing correctly but i have no clue what I have submitted my code below if anyone can please help!





<?php
function printForm($strMessage){
echo "<strong>" .$strMessage."</strong>";
echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF']. "\" name=\"form\">\n";
echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\"
echo  "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"
echo "<input type=\submit\" value=\"send\" name=\"submit\"/>\n";
echo "</form>\n";
}
?>
<html>
<head>
<title>Self Submitting Sticky Form</title>
</head>
<body>
    <?php
    if(isset($_POST['submit'])){
        $firstname=trim($_POST['fname']);
        $lastname=trim($_POST['lname']);
        if ($firstname==''){
        $strMessage='Please enter your first name.';
        printForm($strMessage);
        }
        elseif ($lastname==''){
		        $strMessage='Please enter your last name.';
		        printForm($strMessage);
        }
        else{
        $strMessage='Thank you. your information was sent.';
        echo $strMessage;
        }
     }
     else{
     $strMessage='Please enter all fields below:';
     printForm($strMessage);
     }
     ?>
     </body>
     </html>



Is This A Good Question/Topic? 0
  • +

Replies To: Can you Find my syntax error expecting ',' or ';' plea

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,581
  • Joined: 08-June 10

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 10 February 2013 - 11:52 PM

lines #5 and #6: concatenation between string and trim() missing, closing semi-colon missing.

This post has been edited by Dormilich: 10 February 2013 - 11:52 PM

Was This Post Helpful? 0
  • +
  • -

#3 TheKirk  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 58
  • Joined: 10-February 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 10 February 2013 - 11:54 PM

These lines (on top):

echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\"
06
echo  "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"


Do not end with an ;

Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.

This post has been edited by Dormilich: 10 February 2013 - 11:54 PM

Was This Post Helpful? 0
  • +
  • -

#4 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 12:59 AM

View PostTheKirk, on 11 February 2013 - 01:54 AM, said:

These lines (on top):

echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\"
06
echo  "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"


Do not end with an ;

Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.

Its not that I know what it means but even with you close them like you are saying it will not work for some reason any other ideas
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,581
  • Joined: 08-June 10

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:02 AM

see post #2
Was This Post Helpful? 0
  • +
  • -

#6 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:17 AM

View PostDormilich, on 11 February 2013 - 03:02 AM, said:

see post #2

Thank you for your help I was actually looking at you post but did not understand it exactly I understand the part about the closing semi colon but not the other part any way you could show me those two lines the way they should be thank you
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,581
  • Joined: 08-June 10

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:40 AM

hm, how do you normally concatenate two strings?
Was This Post Helpful? 0
  • +
  • -

#8 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:43 AM

View PostDormilich, on 11 February 2013 - 03:40 AM, said:

hm, how do you normally concatenate two strings?

Not too sure I am pretty new to this
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3390
  • View blog
  • Posts: 9,581
  • Joined: 08-June 10

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:46 AM

since you need it to read anyways:
- string operators
- echo

hint: you’re already doing that in your code
Was This Post Helpful? 0
  • +
  • -

#10 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 01:51 AM

Thanks for your help I'm reading the links but still not quite seeing what I am doing wrong although I am seeing it may have something to do with parentheses
Was This Post Helpful? 0
  • +
  • -

#11 ak4744710  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 127
  • Joined: 30-January 13

Re: Can you Find my syntax error expecting ',' or ';' plea

Posted 11 February 2013 - 02:06 AM

solved thanks for everyone's help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1