PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 11th, 2013, 02:34 AM
ak4744710 ak4744710 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 21 ak4744710 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 5 m 44 sec
Reputation Power: 0
Can you Find my syntax error expecting ',' or ';' please

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! Also before anyone says I am forgeting the closing tags on 5 and 6 test it and see it will not work even with the semi coluns thats what has me so stumped.
<?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>

Reply With Quote
  #2  
Old February 11th, 2013, 02:59 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,845 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 8 h 37 m 27 sec
Reputation Power: 813
C'mon, you know where the PHP forum is, and you should have realized that there's a code highlighter in the forum. Use it. It will actually tell you where the problem is.

Hint: Check those bits at the end of the line:
PHP Code:
"\" 

That's not a complete string, because the closing quote is escaped.

By the way, you can avoid all this escaping by simply wrapping double quotes in a single quoted string (and vice versa):
PHP Code:
echo 'No "escaping" necessary.'

Reply With Quote
  #3  
Old February 11th, 2013, 02:59 AM
simplypixie simplypixie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 104 simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
In lines 5 and 6 you are not only missing the ; but you are also missing the closing > on your input element. This works on my server:

PHP Code:
echo "First Name: <input type=\"text\" name=\"fname\" value=\"" .trim($_POST['fname'])."\">";
echo 
"Last Name: <input type=\"text\" name=\"lname\" value=\"" .trim($_POST['lname'])."\">"
Comments on this post
ak4744710 agrees: thanks

Reply With Quote
  #4  
Old February 11th, 2013, 03:03 AM
ak4744710 ak4744710 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 21 ak4744710 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 5 m 44 sec
Reputation Power: 0
thought I was in php forum sorry about that and thank you to the other person works fine

Reply With Quote
  #5  
Old February 11th, 2013, 03:06 AM
ak4744710 ak4744710 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 21 ak4744710 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 5 m 44 sec
Reputation Power: 0
solved thanks for everyone's help

Reply With Quote
  #6  
Old February 11th, 2013, 07:54 AM
neilfin neilfin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 neilfin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 35 sec
Reputation Power: 0
One of the easier ways to identify bugs is to use a good code editor. I paste your code in Dreamweaver CS6 and it shows me instantly where you did mistake - very easy.

As you've already solved the issue you know the bug was the wrong use of "quotation mark". You can't use double quote within double quote directly. PHP has some predefined rules. There is also trick to use double quote within double too. You can learn how to use different quotes and few tips here - schoolsofweb.com/php-strings/

Hope it will help somebody.

-Neil
Comments on this post
aeternus agrees: I would rather spend that money on some pint, try Netbeans it's free

Reply With Quote
  #7  
Old February 12th, 2013, 10:08 AM
Triple_Nothing Triple_Nothing is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 294 Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 8 h 6 m 9 sec
Reputation Power: 5
Excellent note to pass on, especially to knew coders. Find yourself excellent code editor software you would be comfortable working with. I recommend PSPad to many. A friend of mine has had goode like with Notepad++. And many use Adobe's Create Suites (CS) lines.

Reply With Quote
  #8  
Old February 12th, 2013, 02:24 PM
ak4744710 ak4744710 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 21 ak4744710 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 5 m 44 sec
Reputation Power: 0
Quote:
Originally Posted by Triple_Nothing
Excellent note to pass on, especially to knew coders. Find yourself excellent code editor software you would be comfortable working with. I recommend PSPad to many. A friend of mine has had goode like with Notepad++. And many use Adobe's Create Suites (CS) lines.

I'm going to have to check those out i always use text pad

Reply With Quote
  #9  
Old February 12th, 2013, 02:59 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,791 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 14 h 53 m 20 sec
Reputation Power: 6112
EclipsePDT is a free IDE that's designed specifically for PHP.
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Can you Find my syntax error expecting ',' or ';' please

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap