Current location: Hot Scripts Forums » Programming Languages » PHP » Need help finding PHP code errors


Need help finding PHP code errors

Reply
  #1 (permalink)  
Old 10-07-06, 05:34 PM
Elle0000 Elle0000 is offline
Newbie Coder
 
Join Date: Sep 2006
Location: CT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Need help finding PHP code errors

I have written a simple survey form in HTML. I have written the PHP code, but am still getting a parsing error (line 95). I cannot find it and I am sure that there are others.
I also have a really dumb question. When the error tells you on what line the error is, how exactly do you find the line? I have spaces in between lines and have the code separated so that I can read it (but have removed them below). How do you find the beginning and end of a line, and is there an easy way to count lines. Do the spaces count as lines? I must be missing something because as far as I can tell, line 95 is the closing html tag.

Thanx muchly.

PHP Code:

 code here

<html>
<head>
<title>All About You!</title>
<style type="text/css">
<!--
.style1 {
color: #333399;
font: bold 24px Arial;
text-align: center;
}
.style2 {
color: #333399;
font: bold 14px Arial;
}
.style5 {
font-size: 16px;
color: #330099;
font-family: Arial;
}
-->
</style>
</head>
<body>
<form action="Form.html" method="get">
<p class="style1">All About You!</p>
<strong><p class="style5"> Thank you for telling us about yourself. Below is your information.
<br>
If any items are incomplete, please hit the back button and complete your submission. </p> </strong>
<br><br>
<?php
if ( $First == "" ) {
$error=true;
echo 
"<BR> Please enter your first name";
} else { 
echo 
"Your first name is:  $First."; } 
?>
<br>
<?php
if ( $Last == "" ) {
$error=true;
echo 
"Please enter your last name";
} else { 
echo 
"Your last name is:  $Last."; } 
?>
<br>
<?php
if ( $Color== "" ) {
$error=true;
echo 
"<BR> Please enter your favorite color";
} else { 
echo 
"Your favorite color is:  $Color.";
?>
<br>
<?php
if ( $Meaning == "" ) {
$error=true;
echo 
"Please comment on what your favorite color means to you.";
} else { 
echo 
"What your color means to you:  $Meaning";
?>
<br>
<?php
If ($Gender=="Male") { echo "You indicated that you are male.";
} else {
echo 
"You indicated that you are female"
}
?>
<br><br>
<?php
If ($Ques1=="yes") { echo "You indicated that you are married.";
} else { 
echo 
"You indicated that you not are married.";
}
?>
<br><br>
<?php
If ($Ques2=="yes"){ echo "You indicated that you are employed.";
} else { 
echo 
"You indicated that you are not employed"
}
?>
<br><br>
<?php
If ($Ques3=="yes"){ echo "You indicated that you do like to travel.";
} else { 
echo 
"You indicated that you do not like to travel"
}
?>
<br>
<input type="Submit" value="BACK" name="Submit">
<br>
<p class="style5"> <strong>Thanks again for your time.</strong> </p>
</form>
</body>
</html>
end code
Reply With Quote
  #2 (permalink)  
Old 10-07-06, 05:36 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?php 

if ( $Color== "" ) { 
$error=true
echo 
"<BR> Please enter your favorite color"
} else {  
echo 
"Your favorite color is:  $Color."
?>
PHP Code:

<?php 

if ( $Meaning == "" ) { 
$error=true
echo 
"Please comment on what your favorite color means to you."
} else {  
echo 
"What your color means to you:  $Meaning"
?>
you need a closing bracket like so

PHP Code:

<?php 

if ( $Color== "" ) { 
$error=true
echo 
"<BR> Please enter your favorite color"
} else {  
echo 
"Your favorite color is:  $Color."
}
?>
PHP Code:

<?php 

if ( $Meaning == "" ) { 
$error=true
echo 
"Please comment on what your favorite color means to you."
} else {  
echo 
"What your color means to you:  $Meaning"
}
?>
Reply With Quote
  #3 (permalink)  
Old 10-08-06, 03:01 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Quote:
Originally Posted by Elle0000
I also have a really dumb question. When the error tells you on what line the error is, how exactly do you find the line? I have spaces in between lines and have the code separated so that I can read it (but have removed them below). How do you find the beginning and end of a line, and is there an easy way to count lines. Do the spaces count as lines? I must be missing something because as far as I can tell, line 95 is the closing html tag.
What editor are you using? if you're using adobe dreamweaver, notepad++, zend studios or komodo, you can set an option to display the line numbers.
Yes spaces between lines are counted as seperate lines.

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #4 (permalink)  
Old 10-08-06, 01:18 PM
Elle0000 Elle0000 is offline
Newbie Coder
 
Join Date: Sep 2006
Location: CT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
It's All Over My Head

I am a novice taking an online distance learning course. PHP is a foreign language to me. I don't understand how to code. I pieced it together from 10 different books.

I am not lazy. I have spent many nites awake trying to find info that will help me learn. I spent a lot of time looking online for books. I look through all of them daily and scour the Internet for resources.

Did you ever take a foreign language in high school? Did you ever have to read a book in a foreign language?

How can you weed out the incorrect answers on a test if you can't read them? I don't understand the language, let alone know what sorts errors of errors I seek. I need to see the code correctly to have a chance at understanding it. I'm not lazy. I'm clueless.
Reply With Quote
  #5 (permalink)  
Old 10-08-06, 01:31 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
The line in red is part of his signature. It is not a comment directed at you, it is directed at the people that ask someone else what is wrong with their own code as the first troubleshooting step they take, without having consulted a programming reference manual first.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code 2 convert .doc file into .pdf file jeephp PHP 7 11-03-10 04:31 AM
CGI Code Converting to PHP - need help PHP Warner PHP 4 03-29-06 07:32 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM


All times are GMT -5. The time now is 05:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.