Parse error: parse error, unexpected T_STRING on line 40

Reply

Join Date: Aug 2008
Posts: 10
Reputation: wiccanwolf is an unknown quantity at this point 
Solved Threads: 0
wiccanwolf wiccanwolf is offline Offline
Newbie Poster

Parse error: parse error, unexpected T_STRING on line 40

 
0
  #1
Aug 12th, 2008
Hi, I was wondering if someone could look over my coding? x3 I'm really, really new to PHP (just learning, in fact) and a friend gave me this sample code, but it doesn't seem to work... could someone please help? Thank you so much. <3 Here is the full code:

  1. <?php
  2. include ('connect.php');
  3. ?>
  4.  
  5. <form name="form1" method="post" action="dogstore.php">
  6. Dog's Name:
  7. <input name="dogname" type="text">
  8. <br>
  9. Dog's Breed:
  10. <select name="dogbreed">
  11. <option value="breed1">Breed</option>
  12. <option value="breed2">Breed</option>
  13. <option value="breed3">Breed</option>
  14. <option value="breed4">Breed</option>
  15. <option value="breed5">Breed</option>
  16. <option value="breed6">Breed</option>
  17. <option value="breed7">Breed</option>
  18. </select>
  19. <br>
  20. Dog's Gender:
  21. <select name="doggender">
  22. <option value="Male">Male</option>
  23. <option value="Female">Female</option>
  24. </select>
  25. <br>
  26. <input type="submit" name="Submit" value="Buy Dog">
  27. </form>
  28.  
  29. <?php
  30. //trim removes the white spaces from the beginning and end of the text
  31. $dogname = trim($_POST['dogname']);
  32. $dogbreed = trim($_POST['dogbreed']);
  33. $doggender = trim($_POST['doggender']);
  34. ?>
  35.  
  36. <?php
  37. //Make sure the name form is filled out.
  38. if ((isset($_POST['dogname']))
  39. || ($_POST['dogname'] == "))
  40. die("Oops! You forgot to fill in the name!");
  41. ?>
  42.  
  43. <?php
  44. $ownerid = $_SESSION['id']
  45. ?>
  46.  
  47. <?php
  48. if ((!isset($_POST['Buy Dog']))
  49. {
  50. echo "Congratulations! You've purchased a dog.";
  51. }
  52. else
  53. {
  54. echo "Congratulations! You've purchased a dog.";}
  55. }
  56. ?>
  57.  
  58. <?php
  59. $dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)
  60. VALUES ('$ownerid', '$dogname', '$doggender')") or die("Error:
  61. ".mysql_error());
  62. ?>
  63.  
Last edited by Tekmaven; Aug 12th, 2008 at 5:58 am. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #2
Aug 12th, 2008
Just wondering, where is line 40?

But some errors I spotted:
1. Your "$ownerid = $_SESSION['id']" needs a semicolon.
1. I think that your if ((!isset($_POST['Buy Dog'])) has an extra parentheses at the beginning.
3. And finally, you don't need to keep on opening and closing the php tags. Unless you have HTML or something else in between them, you should just open the tag at the beginning, and then close it only at the end.
Last edited by Demiloy; Aug 12th, 2008 at 1:37 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 10
Reputation: wiccanwolf is an unknown quantity at this point 
Solved Threads: 0
wiccanwolf wiccanwolf is offline Offline
Newbie Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #3
Aug 12th, 2008
I just tried your suggestions, and received this error:

Parse error: parse error, unexpected T_BOOLEAN_OR in C:\Program Files\EasyPHP 2.0b1\www\dogstore.php on line 39
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #4
Aug 12th, 2008
Where's line 39?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 10
Reputation: wiccanwolf is an unknown quantity at this point 
Solved Threads: 0
wiccanwolf wiccanwolf is offline Offline
Newbie Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #5
Aug 12th, 2008
If I counted correctly:

die("Oops! You forgot to fill in the name!");
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #6
Aug 12th, 2008
Wrap your code around [code=php] tags, and post, and they should have automatic line counts. And highlighting, which is tons easier to read.
Last edited by Demiloy; Aug 12th, 2008 at 1:51 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 10
Reputation: wiccanwolf is an unknown quantity at this point 
Solved Threads: 0
wiccanwolf wiccanwolf is offline Offline
Newbie Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #7
Aug 12th, 2008
I tried it so that I had [*code=php] at the top and [*/code] at the bottom, and it gave me:

Parse error: parse error, unexpected T_BOOLEAN_OR in C:\Program Files\EasyPHP 2.0b1\www\dogstore.php on line 41

Argh, evil code, work already. x.X

Edit: Obvious the code was without the *
Last edited by wiccanwolf; Aug 12th, 2008 at 1:54 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #8
Aug 12th, 2008
No, no. Sorry for miscommunication: post that here. Put (no space) and then put the code in between there. Then post all that here so we can see it all better.

Or better yet, edit your original post to do that.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #9
Aug 12th, 2008
In any case, your if structure:
  1. <?php
  2. //Make sure the name form is filled out.
  3. if ((isset($_POST['dogname']))
  4. || ($_POST['dogname'] == "))
  5. die("Oops! You forgot to fill in the name!");
  6. ?>
  7.  
is wrong. You need to put braces around the die function. Also, you need to have two doubles quotes, i.e. || ($_POST['dogname'] == ""))
Last edited by Demiloy; Aug 12th, 2008 at 1:54 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 10
Reputation: wiccanwolf is an unknown quantity at this point 
Solved Threads: 0
wiccanwolf wiccanwolf is offline Offline
Newbie Poster

Re: Parse error: parse error, unexpected T_STRING on line 40

 
0
  #10
Aug 12th, 2008
Eeeep, I don't understand. x.x Okay, let me fix the if structure like you said, and I'll edit my original post to show what I've got.

I'm sorry this is so difficult, I'm really new to coding, and I really appreciate your help. <3
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC