Jump to content
MakeWebGames

Recommended Posts

Posted

hi for some reason i got this message

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/gothcent/public_html/mainmenu.php on line 36

here the code for it

<?php
/**
* MCCodes Version 2.0.5b
* Copyright (C) 2005-2012 Dabomstew
* All rights reserved.
*
* Redistribution of this code in any form is prohibited, except in
* the specific cases set out in the MCCodes Customer License.
*
* This code license may be used to run one (1) game.
* A game is defined as the set of users and other game database data,
* so you are permitted to create alternative clients for your game.
*
* If you did not obtain this code from MCCodes.com, you are in all likelihood
* using it illegally. Please contact MCCodes to discuss licensing options
* in this case.
*
* File: mainmenu.php
* Signature: hidden
* Date: Fri, 20 Apr 12 08:50:30 +0000
*/

if (!defined('jdsf45tji'))
{
   echo 'This file cannot be accessed directly.';
   die;
}
global $db, $c, $ir, $set;
$hc = $set['hospital_count'];
$jc = $set['jail_count'];
$ec = $ir['new_events'];
$mc = $ir['new_mail'];
if ($ir['hospital'])
{
   echo 
'<a href= 'hospital.php'> Hospital ($hc)</a><br />'
'<a href='inventory.php'>Inventory</a><br />'
';
}
elseif ($ir['jail'])
{
   echo '<a href='jail.php'>Jail ($jc)</a><br />';
}
else
{
   echo '<a href='index.php'>Home</a><br />
<a href='inventory.php'>Inventory</a><br />';
}
echo ($ec > 0)
       ? '<a href='events.php' style='font-weight: bold;'>Events (' . $ec
               . ')</a><br />' : '<a href='events.php'>Events (0)</a><br />';
echo ($mc > 0)
       ? '<a href='mailbox.php' style='font-weight: bold;'>Mailbox (' . $mc
               . ')</a><br />' : '<a href='mailbox.php'>Mailbox (0)</a><br />';
if ($ir['jail'] and !$ir['hospital'])
{
   echo '
<a href='gym.php'>Jail Gym</a><br />
<a href='hospital.php'>Hospital ($hc)</a><br />
  	';
}
else if (!$ir['hospital'])
{
   echo '
<a href='explore.php'>Explore</a><br />
<a href='gym.php'>Gym</a><br />
<a href='criminal.php'>Crimes</a><br />
<a href='job.php'>Your Job</a><br />
<a href='education.php'>Local School</a><br />
       <a href='shoutarea.php'>Shoutbox</a><br />
<a href='hospital.php'>Hospital ($hc)</a><br />
<a href='jail.php'>Jail ($jc)</a><br />
  	';
}
else
{
   echo '<a href='jail.php'>Jail ($jc)</a><br />';
}
echo '<a href='forums.php'>Forums</a><br />';
echo ($ir['new_announcements'])
       ? '<a href='announcements.php' style='font-weight: bold;'>Announcements ('
               . $ir['new_announcements'] . ')</a><br />'
       : '<a href='announcements.php'>Announcements (0)</a><br />';
echo '
<a href='newspaper.php' target='_blank'>Newspaper</a>
';
if($set['stafflock'] == 'Locked')
{
echo '$T<a href='<s>Staff Applications</s>' target='_blank'><s><span class='highlight'>Staff</span> Applications</s></a>
';
}
else if($set['stafflock'] == 'Unlocked')
{
echo '$T<a href='http://StaffApps.php' target='_blank'><span class='highlight'>Staff</span> Applications</a>
';
}
echo '
<a href='search.php'>Search</a><br />
<a href='usersonline.php'>Users Online</a><br />';
if($ir['married'] > 0)
{
print'<a href=marriage.php>Manage Marriage</a>';
}
if (!$ir['jail'] && $ir['gang'])
{
   echo '<a href='yourgang.php'>Your Gang</a><br />';
}
if ($ir['user_level'] > 1)
{
   echo '
<hr />
<a href='staff.php'>Staff Panel</a><br />
<hr />
<b>Staff Online:</b><br />
  	';
   $online_cutoff = time() - 900;
   $q =
           $db->query(
                   'SELECT `userid`, `username`, `laston`
                    FROM `users`
                    WHERE `laston` > ({$online_cutoff})
                    AND `user_level` > 1
                    ORDER BY `userid` ASC');
   while ($r = $db->fetch_row($q))
   {
       echo '<a href='viewuser.php?u=' . $r['userid'] . ''>' . $r['username']
               . '</a> (' . DateTime_Parse($r['laston']) . ')<br />';
   }
   $db->free_result($q);
}
if ($ir['donatordays'])
{
   echo '
<hr />
<b>Donators Only</b><br />
       <a href='ddreward.php'>Daily Donator Reward</a><br />
<a href='friendslist.php'>Friends List</a><br />
<a href='blacklist.php'>Black List</a>
  	';
}
echo '
<hr />
<a href='preferences.php'>Preferences</a><br />
<a href='preport.php'>Player Report</a><br />
<a href='helptutorial.php'>Help Tutorial</a><br />
<a href='gamerules.php'>Game Rules</a><br />
<a href='viewuser.php?u={$ir['userid']}'>My Profile</a><br />
<a href='logout.php'>Logout</a><br /><br />
Time is now<br />
' . date('F j, Y') . '<br />' . date('g:i:s a');
Posted

Your echo's should be like this:

echo "<a href='yourlink.php'>Your Link</a>"

And also, your ending you echos after every line and when you do that you need to echo or print again.

Ill use your first lines for an example

if ($ir['hospital'])
{
   echo
   '<a href= 'hospital.php'> Hospital ($hc)</a>'
   '<a href='inventory.php'>Inventory</a>'
   ';

There are a lot of things wrong with this. You halfway ended your echo for the hospital link by not adding a ; then you try to "echo" another link for inventory.

So what you can do is remove the ' after the </a>s and before your <a href on the inventory link and change your ' to " inside your links so it looks like this:

if ($ir['hospital'])
{
   echo
   '<a href="hospital.php"> Hospital ($hc)</a>
   <a href="inventory.php">Inventory</a>
   ';

See what I did here. But my preference is the other way around like this:

if ($ir['hospital'])
{
   print "
   <a href= 'hospital.php'> Hospital ($hc)</a>
   <a href='inventory.php'>Inventory</a>
   ";

To me that way looks cleaner but to each their own

Posted
Your echo's should be like this:
echo "<a href='yourlink.php'>Your Link</a>"

And also, your ending you echos after every line and when you do that you need to echo or print again.

Ill use your first lines for an example

if ($ir['hospital'])
{
   echo
   '<a href= 'hospital.php'> Hospital ($hc)</a>'
   '<a href='inventory.php'>Inventory</a>'
   ';

There are a lot of things wrong with this. You halfway ended your echo for the hospital link by not adding a ; then you try to "echo" another link for inventory.

So what you can do is remove the ' after the </a>s and before your <a href on the inventory link and change your ' to " inside your links so it looks like this:

if ($ir['hospital'])
{
   echo
   '<a href="hospital.php"> Hospital ($hc)</a>
   <a href="inventory.php">Inventory</a>
   ';

See what I did here. But my preference is the other way around like this:

if ($ir['hospital'])
{
   print "
   <a href= 'hospital.php'> Hospital ($hc)</a>
   <a href='inventory.php'>Inventory</a>
   ";

To me that way looks cleaner but to each their own

Could also do this, when using echo, though I personally think it's messier:

echo 
"<a href= 'hospital.php'> Hospital ($hc)</a><br />",
"<a href='inventory.php'>Inventory</a>";
Posted
Could also do this, when using echo, though I personally think it's messier:
echo 
"<a href= 'hospital.php'> Hospital ($hc)</a><br />",
"<a href='inventory.php'>Inventory</a>";

Not a big fan, it kinda confuses me cause if I were to miss a " somewhere I guarantee it would take me like 5 minutes to figure that out cause its alway the obvious that kills me and you of all people should know how I miss stupid crap in something I do haha

Posted

Different strokes and all that. I guess I could sort of see where some would prefer that way.

And yeah, I get you on that. So not looking forward to plugging in this items system. I'm almost certain there will be at least one error, no matter how small, on every page. And so far, it's 15 files and 15 SQL tables.

Posted

On one of the youtube php learning sites ...

It says that using echo ' blah ' is faster than echo "blah" or print "blah".

I don't know if anyone has ever tested this or not. *shrugs* As Seker said ... different strokes and all that.

Posted (edited)

single quotes are faster, but not by much you would barely see it, if you're not using $vars in an echo statement with double quotes, then you should use single, because double parses the string, what i have read long time ago forgot the name of the website, but they did the test on it.

@raven

if ($ir['hospital'])

{

echo

'<a href= 'hospital.php'> Hospital ($hc)</a>'

'<a href='inventory.php'>Inventory</a>'

';

}

do you see the error? there are quotes around

' <a href= 'hospital.php'> Hospital ($hc)</a> '

' <a href='inventory.php'>Inventory</a> '

it should be :

if ($ir['hospital'])

{

echo

'<a href="hospital.php"> Hospital ('.$hc.')</a>

<a href="inventory.php">Inventory</a>';

}

 

echo statement should look like this:

echo ' '; (if using this one then you would use double quotes in the statement such as :<a href="inventory.php"> For $vars it would be '.$var.').

OR

echo " "; (if using this one then you would use single quotes in the statement such as :<a href='inventory.php'> For $vars it would be {$var} or just $var just depends).

Edited by lucky3809
Posted

@raven

if ($ir['hospital'])

{

echo

'<a href= 'hospital.php'> Hospital ($hc)</a>'

'<a href='inventory.php'>Inventory</a>'

';

}

do you see the error? there are quotes around

' <a href= 'hospital.php'> Hospital ($hc)</a> '

' <a href='inventory.php'>Inventory</a> '

it should be :

if ($ir['hospital'])

{

echo

'<a href="hospital.php"> Hospital ('.$hc.')</a>

<a href="inventory.php">Inventory</a>';

}

 

echo statement should look like this:

echo ' '; (if using this one then you would use double quotes in the statement such as :<a href="inventory.php"> For $vars it would be '.$var.').

OR

echo " "; (if using this one then you would use single quotes in the statement such as :<a href='inventory.php'> For $vars it would be {$var} or just $var just depends).

Spot on, thats what I was trying to say lol but I was on my phone and I have a tendancy to ramble on and forget what im trying to say haha

  • 2 weeks later...
Posted

Your error is because you are using the same quotation marks as the echo is using. If you start your output using ' you can not use ' within the output unless it's properly escaped.

 

Your echo's should be like this:
echo "<a href='yourlink.php'>Your Link</a>"

 

To expand on that, you should end your echo with a ;

So it should be

echo 'The text being shown';

 

Also, when outputting variables within an echo, I use the following:

 

echo "This is a ".$variable." believe it or not";

 

The easiest way to keep yourself right is to make sure you have an even number of quotes.

The single quote ( ' )/double quote ( " ) thing is made out to be a bigger deal than it is. I prefer to use double quotes for 2 reasons. I prefer to have single quotes in my visible source code, and also if I'm going to have text saying something containing a single quote such as "You're in hospital", I can do so without creating an error.

Posted
Your error is because you are using the same quotation marks as the echo is using. If you start your output using ' you can not use ' within the output unless it's properly escaped.

 

To expand on that, you should end your echo with a ;

So it should be

echo 'The text being shown';

 

Also, when outputting variables within an echo, I use the following:

 

echo "This is a ".$variable." believe it or not";

 

The easiest way to keep yourself right is to make sure you have an even number of quotes.

The single quote ( ' )/double quote ( " ) thing is made out to be a bigger deal than it is. I prefer to use double quotes for 2 reasons. I prefer to have single quotes in my visible source code, and also if I'm going to have text saying something containing a single quote such as "You're in hospital", I can do so without creating an error.

Well as long as you know what your doing it doesnt matter

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...