Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unexpected $end

Status
Not open for further replies.

M2E

IS-IT--Management
Aug 1, 2005
28
GB
I have a very simple script - however no matter what I do I can not seem to get rid of this error that I keep getting:


Parse error: syntax error, unexpected $end in /home/ghanabla/public_html/scripts/subscribe.php on line 168

I have pasted the code below:

----code below----
<?php

#ensure all fields have entries
if ($email)
{
#connect to mysql
$conn=@mysql_connect("localhost", "ghanabla_gbsnweb", "ghana50") or die ("Err:Conn");

#select the specified database
$rs = @mysql_select_db("ghanabla_gbsn", $conn) or die ("Err:Conn");

#create the query
$sql="INSERT INTO subscribed_emails(email) VALUES ($email)";

#execute query
$rs=mysql_query($sql,$conn);

#confirm the added record details
if($rs) { echo("Thankyou for registering with the GBSN"); }
}
?>

----Ment2Excel (M2E)----
--LEARN BY EXAMPLE--
 
There is some type of punctuation which must come in pairs (such as {}, [] or () ). In your script, the closing match of that pair is missing somewhere.

Your indentation style will make it hard to find the missing pair.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Hi,

This is what every link on the internet is saying - but have I have been through a couple of times and everything seems to be matching up...

--code--

<?php

#ensure all fields have entries
if ($email)
{

#connect to mysql
$conn=@mysql_connect("localhost", "ghanabla_gbsnweb", "ghana50") or die ("Err:Conn");

#select the specified database
$rs = @mysql_select_db("ghanabla_gbsn", $conn) or die ("Err:Conn");

#create the query
$sql="INSERT INTO subscribed_emails(email) VALUES ($email)";

#execute query
$rs=mysql_query($sql,$conn);

#confirm the added record details
if($rs) { echo("Thankyou for registering with the GBSN"); }
}


----Ment2Excel (M2E)----
--LEARN BY EXAMPLE--
 
The error you posted reads, "unexpected $end in /home/ghanabla/public_html/scripts/subscribe.php [red]on line 168[/red]".

The code you've posted does not have that many lines.



Want the best answers? Ask the best questions! TANSTAAFL!
 
I've stripped it down in order to find out the prob.
Basically the error is always the last line (a blank line)
of the code.

Thanks

----Ment2Excel (M2E)----
--LEARN BY EXAMPLE--
 
sleipnir214 is right
Do you use a PHP editor that highlights/matches tags, brakets et...
 
When PHP reports a parse error, it's basically saying, "Your code has confused me".

The problem is that PHP reports parse errors at the line at which it realized it was confused, not necessarily at the line where the actual error occurred. I've had the error actually sitting hundreds of lines before where PHP reported the error.

As webdev007 has said, getting a good text editor can help. Commenting out blocks of code, starting from the end and working your way forward can help, too, to see where the actual typo is.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top