Parse error: syntax error, unexpected $end

Reply

Join Date: Dec 2007
Posts: 28
Reputation: abhi287 is an unknown quantity at this point 
Solved Threads: 0
abhi287 abhi287 is offline Offline
Light Poster

Parse error: syntax error, unexpected $end

 
0
  #1
Feb 16th, 2008
Hi all

I m using following code..
  1. <?php
  2. session_start();
  3.  
  4. if(!isset($_SESSION['captcha'])){session_register('captcha');}
  5. $PHP_SELF = $_SERVER['PHP_SELF'];
  6. $stringa = '';
  7. $cifre = 5;
  8. for($i=1;$i<=$cifre;$i++){
  9. $letteraOnumero = rand(1,2);
  10. if($letteraOnumero == 1){
  11. // lettera
  12. $lettere = 'ABEFHKMNRVWX';
  13. $x = rand(1,11);
  14. $lettera = substr($lettere,$x,1);
  15. $stringa .= $lettera;
  16. } else {
  17. $numero = rand(3,7);
  18. $stringa .= $numero;
  19. }
  20. }
  21. $_SESSION['captcha'] = $stringa;
  22. ?>
  23. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <link rel="stylesheet" type="text/css" href="css/styles.css" />
  27. </head>
  28. <body>
  29. <table width="100" height="54" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="Table_01">
  30. <tr>
  31. <td height="39" align="left" valign="top" class="imagesstyle"><h1 class="style2"><img src="3EImages/dot3E.jpg" alt="" width="29" height="29" align="left" class="imagesstyle" />General Enquiry<br />
  32. </h1>
  33. <td height="39" valign="top" style="padding-top: 5px"><a href="http://www.3esolutionsindia.com/" target="_blank">Home</a></td>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td align="left" valign="top" class="tableDetail"><p><img src="3EImages/ContactUs/Enquiry.jpg" width="170" height="124" align="right" class="imgbrdr" /><strong>Thanks for showing interest in 3E Solutions.</strong> <br />
  38. <br />
  39. Kindly fill all the required fields. We will get in touch with you within 24 hours.</p>
  40. <p>&nbsp;</p>
  41. <form id="captchaform" action="enquiry.php" method="post" style="width:300px;">
  42. <p align="right"> <label>
  43. *Name:
  44. <input type="text" name="name" id="name" size="30"/>
  45. </label></p>
  46. <p align="right">*Email Address:
  47. <label>
  48. <input type="text" name="email" id="email" size="30" />
  49. </label>
  50. </p>
  51. <p align="right">Phone No:
  52. <label>
  53. <input type="text" name="phone" id="phone" size="30" />
  54. </label>
  55. </p>
  56. <p align="right" style="">Interseted in:
  57. <label>
  58. <textarea name="interested" cols="30" rows="6" wrap="physical" id="interested">
  59. </textarea>
  60. </label>
  61. </p>
  62. <p align="right">
  63. <div id="captcha">
  64. <p align="right"><img src="captcha.php" />&nbsp;&nbsp;</p>
  65. <p align="right"><label for="code">*Enter Code: </label>
  66. <input type="text" name="code" id="code" size="30" /></p>
  67. </div>
  68. </p>
  69. <p align="right"><input type="submit" name="button" id="button" value="Submit" style="font-size:small;color: black;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
  70. </form>
  71. </td>
  72. </tr>
  73. </table>
  74. </body>
  75. </html>
and getting arror as--
Parse error: syntax error, unexpected $end in /home/esolutio/public_html/enquirycaptcha.php on line 1


i m not getting where is the problem..
plz reply.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #2
Feb 16th, 2008
I ran your script and I didn't get any error. Maybe you are getting the error because there is no space after
if(!isset($_SESSION['captcha'])){session_register('captcha');}
Replace this line by this.
  1. if(!isset($_SESSION['captcha'])){ session_register('captcha'); }

Cheers,
Naveen
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 4
Reputation: cmarkme is an unknown quantity at this point 
Solved Threads: 0
cmarkme cmarkme is offline Offline
Newbie Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #3
Feb 16th, 2008
unexpected generaly means youve missed a '}' somwhere and php parser has reached the end of the script expecting it get used to error checking
1) get a decent text editor i use textpad which is so so.
2) using your new editor remove parts of code and trial the script until it runs smoothly that way you will narrow down the location of the error.
3) if you find you have messed your script up just (ctrl z)undo it and it will regress to its former state

im fairly new at php but there hasnt been an error that hasnt got passed my 'trial and error' above. hope i helped
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 4
Reputation: cmarkme is an unknown quantity at this point 
Solved Threads: 0
cmarkme cmarkme is offline Offline
Newbie Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #4
Feb 16th, 2008
ORIGINAL
<?php
session_start();

if(!isset($_SESSION['captcha'])){session_register('captcha');}
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
$letteraOnumero = rand(1,2);
if($letteraOnumero == 1){
// lettera
$lettere = 'ABEFHKMNRVWX';
$x = rand(1,11);
$lettera = substr($lettere,$x,1);
$stringa .= $lettera;
} else {
$numero = rand(3,7);
$stringa .= $numero;
}
}


FIXED

<?php
session_start();

if(!isset($_SESSION['captcha'])){session_register('captcha');}
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
$letteraOnumero = rand(1,2);
if($letteraOnumero == 1){
// lettera
$lettere = 'ABEFHKMNRVWX';
$x = rand(1,11);
$lettera = substr($lettere,$x,1);
$stringa .= $lettera;
} }else {
$numero = rand(3,7);
$stringa .= $numero;
}
}
Last edited by cmarkme; Feb 16th, 2008 at 4:36 am. Reason: IGNORE I MADE A MISTAKE
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #5
Feb 16th, 2008
Originally Posted by cmarkme View Post
ORIGINAL
<?php
session_start();

if(!isset($_SESSION['captcha'])){session_register('captcha');}
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
$letteraOnumero = rand(1,2);
if($letteraOnumero == 1){
// lettera
$lettere = 'ABEFHKMNRVWX';
$x = rand(1,11);
$lettera = substr($lettere,$x,1);
$stringa .= $lettera;
} else {
$numero = rand(3,7);
$stringa .= $numero;
}
}


FIXED

<?php
session_start();

if(!isset($_SESSION['captcha'])){session_register('captcha');}
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
$letteraOnumero = rand(1,2);
if($letteraOnumero == 1){
// lettera
$lettere = 'ABEFHKMNRVWX';
$x = rand(1,11);
$lettera = substr($lettere,$x,1);
$stringa .= $lettera;
} }else {
$numero = rand(3,7);
$stringa .= $numero;
}
}
That wouldn't fix anything. There is a } at the end which is for 'for loop'. You just closed the 'for loop' after 'if loop'. That would generate an error
Parse error: syntax error, unexpected T_ELSE
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 28
Reputation: abhi287 is an unknown quantity at this point 
Solved Threads: 0
abhi287 abhi287 is offline Offline
Light Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #6
Feb 16th, 2008
Actually i m getting this error when i upload my page on the web..
insted when i run this on my pc, it won't generate any error..

So what can i do..

plz help..
thnks all...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #7
Feb 16th, 2008
That's strange! do you have error_reporting turned on on your local system ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 28
Reputation: abhi287 is an unknown quantity at this point 
Solved Threads: 0
abhi287 abhi287 is offline Offline
Light Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #8
Feb 16th, 2008
I dont know about that..

How to check that??
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #9
Feb 16th, 2008
Open php.ini and search for display_errors. If its off, turn it On. Then look for error_reporting. Uncomment this line. error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT .
Or, add ini_set("display_errors","On"); error_reporting(E_ALL); in your script.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 28
Reputation: abhi287 is an unknown quantity at this point 
Solved Threads: 0
abhi287 abhi287 is offline Offline
Light Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #10
Feb 17th, 2008
I m still getting the problem..

i've checked php.ini
All the settings are correct..

But it is happing so.. Is there need extra setting while uploading the php..

plz help..
thanks..
Reply With Quote Quick reply to this message  
Reply

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




Views: 4041 | Replies: 11
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC