Help with error message
Moderator: General Moderators
Help with error message
I am working on a main page for my website. Without going into too much detail, it keeps on saying that it finds an unexpected $, always on the last line of my file( I tried adding spaces to see what happened; always was on the last line of code). Does anyone have any idea what is going on? thanks
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Help us help you. Please post the code (inbetween ) and the full error message. Also consider reading this guide: Posting Code in the Forums.
-- Scorphus
Code: Select all
and-- Scorphus
ok i figured you would need the code. It's really long. Basically it checks to see what resolution and what browser the user has and then includes files based on that.
Here's the code:
$error1 = " ";
$error2 = " ";
$error3 = " ";
$errormessage = "The file <b>".$loc."</b> doesn't exist. <br><br>
If you clicked a link to get here, please <a href=\"mailto:pgr@paqmangames.com?subject=TTS Broken Link&body=$loc\" target=\"_new\"><u>Report It Here</u></a>.";
$loc = $id.".html";
If ($browsername == "Netscape") {
If ($screenwidth >= 1024) {
echo $error1;
}
If ($screenwidth < 800) {
echo $error3;
}
}
If ($browsername == "Microsoft Internet Explorer") {
If ($screenwidth < 800) {
echo $error2;
}
If ($screenwidth == 800) {
include("index/index2_1.html");
if(!$php){
if($id) {
if(file_exists($loc))
{
echo $loc;
}
else {
echo $errormessage;
}
}
if($loc == ".html") {
echo "welcome.html";
}
}
if($php="1"){
$phploc = $id.".php";
if($id) {
if(file_exists($phploc))
{
echo $phploc;
}
}
}
include("index/index2_2.html");
}
If ($screenwidth >= 1024) {
include("index/index1_1.html");
if(!$php){
if($id) {
if(file_exists($loc))
{
echo $loc;
}
else {
echo $errormessage;
}
}
if($loc == ".html") {
echo "welcome.html";
}
}
if($php="1"){
$phploc = $id.".php";
if($id) {
if(file_exists($phploc))
{
echo $phploc;
}
}
}
include("index/index1_2.html");
}
$screenwidth and $browsername are variables which are already as cookies by a previous page. $id is in the web address. The basic format is for a page with a changeable window in the middle. I used photoshop to make a really 'pretty' layout. I removed the error messages to shorten this post. I'm sure it's just one too many brackets or something like that. If you have any ways for me to shorten the code using functions or something i would love to hear it.
THANKS
Here's the code:
$error1 = " ";
$error2 = " ";
$error3 = " ";
$errormessage = "The file <b>".$loc."</b> doesn't exist. <br><br>
If you clicked a link to get here, please <a href=\"mailto:pgr@paqmangames.com?subject=TTS Broken Link&body=$loc\" target=\"_new\"><u>Report It Here</u></a>.";
$loc = $id.".html";
If ($browsername == "Netscape") {
If ($screenwidth >= 1024) {
echo $error1;
}
If ($screenwidth < 800) {
echo $error3;
}
}
If ($browsername == "Microsoft Internet Explorer") {
If ($screenwidth < 800) {
echo $error2;
}
If ($screenwidth == 800) {
include("index/index2_1.html");
if(!$php){
if($id) {
if(file_exists($loc))
{
echo $loc;
}
else {
echo $errormessage;
}
}
if($loc == ".html") {
echo "welcome.html";
}
}
if($php="1"){
$phploc = $id.".php";
if($id) {
if(file_exists($phploc))
{
echo $phploc;
}
}
}
include("index/index2_2.html");
}
If ($screenwidth >= 1024) {
include("index/index1_1.html");
if(!$php){
if($id) {
if(file_exists($loc))
{
echo $loc;
}
else {
echo $errormessage;
}
}
if($loc == ".html") {
echo "welcome.html";
}
}
if($php="1"){
$phploc = $id.".php";
if($id) {
if(file_exists($phploc))
{
echo $phploc;
}
}
}
include("index/index1_2.html");
}
$screenwidth and $browsername are variables which are already as cookies by a previous page. $id is in the web address. The basic format is for a page with a changeable window in the middle. I used photoshop to make a really 'pretty' layout. I removed the error messages to shorten this post. I'm sure it's just one too many brackets or something like that. If you have any ways for me to shorten the code using functions or something i would love to hear it.
THANKS
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Ok, now we have the source code, nice. But it seems to me that you forgot to check the Posting Code in the Forums topic.
With best regards,
Scorphus.
Anyways, your code is missing an ending }, here it is, corrected (should be working now):As I wrote:(...) Please post the code (inbetween) (...) Also consider reading this guide: Posting Code in the Forums. (...)Code: Select all
and
Code: Select all
<?php
$error1 = " ";
$error2 = " ";
$error3 = " ";
$errormessage = "The file <b>".$loc."</b> doesn't exist. <br><br>
If you clicked a link to get here, please <a href="mailto:pgr@paqmangames.com?subject=TTS Broken Link&body=$loc" target="_new"><u>Report It Here</u></a>.";
$loc = $id.".html";
If ($browsername == "Netscape")
{
If ($screenwidth >= 1024)
{
echo $error1;
}
If ($screenwidth < 800)
{
echo $error3;
}
}
If ($browsername == "Microsoft Internet Explorer")
{
If ($screenwidth < 800)
{
echo $error2;
}
If ($screenwidth == 800)
{
include ("index/index2_1.html");
if (!$php)
{
if ($id)
{
if (file_exists ($loc))
{
echo $loc;
}
else
{
echo $errormessage;
}
}
if ($loc == ".html")
{
echo "welcome.html";
}
}
if ($php = "1")
{
$phploc = $id.".php";
if ($id)
{
if (file_exists ($phploc))
{
echo $phploc;
}
}
}
include ("index/index2_2.html");
}
If ($screenwidth >= 1024)
{
include ("index/index1_1.html");
if (!$php)
{
if ($id)
{
if (file_exists ($loc))
{
echo $loc;
}
else
{
echo $errormessage;
}
}
if ($loc == ".html")
{
echo "welcome.html";
}
}
if ($php = "1")
{
$phploc = $id.".php";
if ($id)
{
if (file_exists ($phploc))
{
echo $phploc;
}
}
}
include ("index/index1_2.html");
}
}
?>Scorphus.
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Hummm... taking a close look at your code, I figure out some errors:
This if condition of lines 54 and 88 will always evaluate to true. That's because it is an assignment, and this kind of assignment always return true. You should want to do this:
Also, you asked for a shorter code. I'll show you how you can achieve that, with the first part of your script, the rest stays up to you:
This way it becomes shorter and a bit faster (because of some else's here and there).
-- Scorphus
Code: Select all
if ($php = "1")Code: Select all
if ($php = "1")Code: Select all
if ($php == "1")Code: Select all
if ($php == "1")Code: Select all
<?php
$error1 = " ";
$error2 = " ";
$error3 = " ";
$errormessage = "The file <b>".$loc."</b> doesn't exist. <br><br>
If you clicked a link to get here, please <a href="mailto:pgr@paqmangames.com?subject=TTS Broken Link&body=$loc" target="_new"><u>Report It Here</u></a>.";
$loc = $id.".html";
if ($browsername == "Netscape")
if ($screenwidth >= 1024)
echo $error1;
else if ($screenwidth < 800)
echo $error3;
else if ($browsername == "Microsoft Internet Explorer") {
if ($screenwidth < 800)
echo $error2;
else if ($screenwidth == 800) {
?>-- Scorphus