[Help] unexpected end of file

Hi

i use this source to make my php page but i have this nooby error:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\pg\index.php on line 67

The line 67 is " "

i checked my source line by line but i cant find missing “?>” so i think its my programming fault :smiley: (i am starter)
pleas check my source and help me.

Thank you.

My code is:

[php]

<?php error_reporting(E_ERROR | E_WARNING); if(empty($_GET["page"]) || !file_exists("pages/".$_GET["page"].".php")) { header("location: status"); exit; } define("ROOT", dirname(__FILE__)); require_once("includes/html_api.php"); require_once("menu.cfg"); function gen_leds($titles) { ?>
<table style="width: 100%">
    <? foreach($titles as $id=>$title) { ?>
    <tr>
        <td class="status-led led-td-<?=$id ?>"><img id="led-<?=$id ?>" width="64" height="64" title="<?=$title ?>" alt="<?=$title ?>" src="http://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/64x64/Box_Grey.png" /></td>
        <td class="status-text text-<?=$id ?>" style="font-size: 16px; text-align: left"><?=htmlentities($title) ?></td>
    </tr>
    <? } ?>
</table>
<? } ?> <? include("templates/meta.html"); ?> plusgamer.<?=$_GET["page"] ?> <? include("templates/fonts.html"); ?> <? include("templates/styles.html"); ?> <? include("templates/scripts.html"); ?>
plusgamer.<?=$_GET["page"] ?>
<?php menu(); ?>
<? require("pages/".$_GET["page"].".php"); ?>
<div style="text-align: center; font-size: 50px; padding-top: 50px; color: #fea; font-family: Zeyada, cursive;">
    <p>Merry Christmas Guys!</p>
</div>
<div style="text-align: center; font-size: 8px; padding-top: 50px; color: #444">
    <p>This status page is being maintained by Icedream, not by the PG staff. &copy; 2012 Icedream. Hosted by <a href ="http://plusgamer.net/forum/memberlist.php?mode=viewprofile&u=8206"> MAGIC</a>.</p>
</div>

<iframe style="width: 1px; height: 1px; position: absolute; left: -100px; top: -100px" src="http://178.33.27.16/pg/ircmon.php?referer=<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>">
</iframe>
</body>
[/php]

You have a lot of errors in this code.

First, never use short start codes for PHP. On some versions and some servers it causes issues.
So, never use <? to start PHP code lines. Always use <?PHP as it should be. You use both and it
is confusing to read.

Next, this line: header(“location: status”); goes nowhere. It should not just be “status”, but,
it should be a page name such as “status.php” or other filename.

This line: <?php menu(); ?> is not clear on what it does. Normally you would load a variable with
whatever the menu() function creates and then echo it out. A blank function placed like that does
not make sense to the reader and is not clear what it does.

Lastly, this line near the end:
src=“http://178.33.27.16/pg/ircmon.php?referer=<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>”>
is very messy. It appears to loading an “iFrame” from a static server page. But, it it appears that it
will not work as is. First, if the URI pulled from the server is added to the HTTP_HOST it may or may not
be what you are looking for. Also, it may be missing the “/” between them. Lastly, if you are sending
this to the “iFrame” using $_GET[], most likely you need to add quotes around the text. Otherwise, it
will not be pulled correctly in the ircmon.php page. I would alter that page to echo the $referer variable
to see what it has inside it.

So most of that is minor except how you are creating the referer variable. 99% of the time the error you
are getting “unexpected end of file” is caused either by missing a ending “}” or an output from a variable
is adding in the incorrect numbers of quotes or double quotes. You should echo all of your variables to
see which one is in error.

Good luck, hope that helps you find it…

Thank you for very nice explain.
in this topic i just posted my index page but i have a project that included needed files.
If possible for you and if you have free time now i linked my little project to you pleas check that and pleas if possible see what i must do.
Thank you.

Well, one error is line #8 in the posted code below. It should be changed to:
header(“location: pages/status.php”);
You have a check for a page variable that is sent from the calling page. If the page is empty,
it is supposed to redirect to the status page. But, you just put in “status” not the filename and
the folder it is in.

Thank you on sending me the site as I now understand what that line was trying to do.

Now, the other issue is that you are doing this testing on your local system using XAMPP.
Therefore, you have a problem with the way this site is accessed. The very first thing that it
does is check for the “PAGE” variable. Since you are calling the page directly, that variable
does not exist. This means that the “PAGE” value will always be empty and it will always go
to the “status.php” file. Instead, it should go to your login file.

Do you understand this? You are testing for a variable $_GET[“page”] ! And, this variable does
not exist if you are loading your index.php file directly. It will only be there if the index.php file
is called from another page and uses the page option. Like: index.php?page=trollman

Hope that explains it…

Thank.
i know about that status.php. just skip this line ;D
But problem is not this page and also i use “http://127.0.0.1/4d1/?page=iw5msl” but its have multiple errors :frowning:

pleas use that in your local.
Thank you.

Edit:
when i use url : http://127.0.0.1/4d1/?page=iw5msl
i have this error

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\4d1\index.php on line 56

:-\

Well, you would have to use http://127.0.0.1/4d1/index.php?page=iw5msl I think.

But, I have my local system set up now. I have to leave for a few hours and will try to fix it for you
when I get back. So, check here in a few hours to see what I found.

again: :frowning: :frowning:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\4d1\index.php on line 56

are you tested on your local?!

i am confused :frowning:

Very sorry for the delay. I had to work all day yesterday and last night I had plans.
Today, I am busy for a few more hours.

I did get your site that you sent me in place and will be able to fix it later today.

Again, my time got short the last couple days. Hopefully I will have a fix for you later today.
More then…

Thank you so much :-* :-*

Raminr,
I finally got some time to look deeper into your errors. These are what I found so far…

First, inside your META coding that you used inside the meta.html file is incorrect. There are three of
the meta names that you are using that are not valid. Here are the meta names with the three bad
ones commented out:
[php]

[/php] Here is a link to the meta names that are valid for future jobs: [url=http://www.w3schools.com/tags/tag_meta.asp]http://www.w3schools.com/tags/tag_meta.asp[/url] (Go down about half way to the section named "Attributes"...)

Next, in the index.php file, you have several errors which are just formatting problems.
Basically it is just the way you try to code PHP to post a variable out to the HTML part of the page.
Here is one example line:
[php]

<?=$title ?>
[/php]
As you see, this has PHP code embedded in the table’s display like <?=$title ?> . This will not work as
you think it should. First, I always use the full start to PHP code so that it is easy to pick out in your
page’s code. So, " <? " should always be " <?PHP " . Why? Well, some editors can cause the question
mark to be read as a tag and this does cause issues sometimes. I can’t remember the editor that is the
main one I had problems with, but, take my word for this one. Also, I no longer use the short code for
printing or echoing as it also can be read wrong. So, " = " for a PHP command should be " echo " or it
can be the print command. I always use echo, but that is my choice. Lastly, the biggest problem is that
you did not end the PHP commands. You gave a command like " =$title " but did not end it " =$title; " ! ! !
That is the main problem as PHP just keeps going with the command until it finds the end char " ; ".
So, your example <?=$title ?> should become <?PHP echo $title; ?> instead. I took the line above and
changed it to:
[php]
		<td class="status-led led-td-<?PHP echo $id; ?>"><img id="led-<?PHP echo $id; ?>" width="64" height="64" title="<?PHP echo $title; ?>" alt="<?PHP echo $title; ?>" src="http://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/64x64/Box_Grey.png" /></td>

[/php]
Not that I changed the four places you printed/echo’d variables. I also changed the next line and any
others like it. This removed the errors from my local version.

So, make those changes and try it again. (Basically, this is what I mentioned in the very first reply to you!)
Hope that help. If so, let us know so we can close the thread. If not, let me know the errors you get.

One final note: Once your code is online, you can send it thru the W3-Validator. This is a widely used
online validation system that will take your pages code and tell you if it has any formatting problems.
I did not take the time to do this for your pages as I do not want to put it online. This is a great way
to show up errors such as the meta name ones. It would tell you what is wrong and it also checks out
your HTML, CSS and PHP code for common errors. Most professional programmers pass their final code
thru it. Here it their link, just enter your URL when it is working: http://validator.w3.org/

WOW awesome really big thanks for helping .
i will do what you say. i hop its work.

:o
i am wondering…
before any change on my script i decided to tested on Linux host and its work very well
But this script have problem on windows !!!

pleas see here http://plusgamer.ir/4d1/

as you see work very well excep one thing:

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/srv/iw5msl/serverinfo.txt) is not within the allowed path(s): (/home:/usr:/tmp) in /home/plusgame/public_html/4d1/pages/iw5msl.php on line 7

and i need to run on windows server to include this file.

Well, looks like you are almost there…

That message is a warning. You have this code near the top of your file:
error_reporting(E_ERROR | E_WARNING);

That tells your site to show all warnings. Normally, you would leave this line in while testing.
And, comment it out for the live site. (Otherwise, the user’s will see all the code warnings.)

But, the errors talks about a “file exists” problem in line 7. Is line 7 your new version of the
header redirection line? If so, post the new version so we can see if it is really an error or if
it is just a warning.

i know about that error because of there is no file to find that.
But my questions is why in linux host there is no problem and my script run as well but on windows host have syntax error (the error i posted in first post of this topic).

When you say it works on the Linux Server and not on the Windows Host do you mean that you have two servers? Or, do you mean one server and one local Windows computer running Wampp or Xamp?

You should get the same errors on two servers, one based on Linux and one based on Windows Server.

If you mean an emulated server running on a Windows computer, then, it could be a missing file
that doesn’t match or your local computer may not have exactly the same versions of PHP.

You can test that by adding this on BOTH the local and remote-live servers.

phpinfo();

Just add it to the first line of your first page on each. Then go to the page. You will see the PHP info
displayed as a table. You would have to print it out or bring them up side by side and compare all of
the large list of options to see if any differ.

Not sure if that answers your question. This last error is not the same as the first one at the top of
the thread. We fixed that first one by fixing all the syntax errors. Hope that helps.

Hi dear @ErnieAlex

sorry for my delay in some days.

Finally i could resolve my problem because of your nice help.
now i can use my scrip : status.plusmaster.ir

req CLOSE/

Thanks for letting us know. We will be here when you need further help. Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service