[Solved] Why do I get this error with this code?

Hello There!

Well I’m using a VB hack so useres can login offsite.

Code:

					[php]					<?php

If ($vbulletin->userinfo[‘userid’]!=0)
{
echo "

										<table width="181" border="0" cellspacing="0" cellpadding="0" id="table28">



												<tr>



													<td width="15"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="40"></td>



													<td width="166" class="text2">

													My BSE</td>



												</tr>



											</table></td>



									</tr>



									<tr>



										<td style="background-image:url('http://www.battlestationextreme.com/images/homepage10.jpg'); height:29px">

										<table width="100%" border="0" cellspacing="0" cellpadding="0" id="table29">



												<tr>



													<td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td>



													<td width="92%">

													<a class="link1" href="http://www.battlestationextreme.com/forums/usercp.php">

													Register!</a></td>



												</tr>



											</table></td>



									</tr>



									<tr>



										<td style="background-image:url('http://www.battlestationextreme.com/images/homepage10.jpg'); height:29px">

										<table width="100%" border="0" cellspacing="0" cellpadding="0" id="table30">



												<tr>



													<td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td>



													<td width="92%">

													<a class="link1" href="http://www.battlestationextreme.com/forums/private.php">

													Login</a></td>



												</tr>



											</table></td>";
} else {
echo "Your not logged in so we display this";
}

?>[/php]
Error:

Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/------/public_html/homepage.php on line 1016

And line 1016 is:
[php]
echo “Your not logged in so we display this”;[/php]
I can’t see whats wrong there.

If some one could help me out this would be great.

Cheers,
Carl

ADMIN EDIT: Altered [CODE] tags to [PHP] Tags for readability

Ok… Step ONE! Get rid of all the obnoxious white space that is poorly formated.

Using White space is a good tool for making code readable and separating sections… but what you posted is beyond what I would consider normal white space formatting.

Next… this is where syntax highlighting is wonderful… As you can see I have altered the [ CODE ] Tags to make the [ PHP ] tags which changes how things look, and it becomes more clear what the problem MIGHT be.

It looks like you may have missed a double quote escaping somewhere (or escaped the wrong one.) Anyway, there is no need to escape all those double quotes. Since that whole block is just (basically) static text, save yourself the trouble and use the single quote to surround the text. No php inside it so it’s not a problem. Then get rid of all the extraneous escaping (and the white space). A little clean up and you get:

[php]

<?php If ($vbulletin->userinfo['userid']!=0) { echo '
My BSE
Register!
Login
'; } else { echo "Your not logged in so we display this"; } ?>

[/php]

You can then see a big difference in the syntax highlighting.

You could also just close the PHP tags do the html… then open the php tags again and continue.

[php]

<?php If ($vbulletin->userinfo['userid']!=0) { ?>
<td style="background-image:url("http://www.battlestationextreme.com/images/homepage09.jpg"); height:40px">
  <table width="181" border="0" cellspacing="0" cellpadding="0" id="table28">
    <tr>
      <td width="15"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="40"></td>
      <td width="166" class="text2"> My BSE</td>
    </tr>
  </table>
</td>
  </tr>

  <tr>
    <td style="background-image:url("http://www.battlestationextreme.com/images/homepage10.jpg"); height:29px">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table29">
        <tr>
          <td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td>
          <td width="92%"><a class="link1" href="http://www.battlestationextreme.com/forums/usercp.php">Register!</a></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td style="background-image:url("http://www.battlestationextreme.com/images/homepage10.jpg"); height:29px">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table30">
        <tr>
          <td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td>
          <td width="92%"><a class="link1" href="http://www.battlestationextreme.com/forums/private.php">Login</a></td>
        </tr>
       </table>
     </td>
<? } else { echo "Your not logged in so we display this"; } ?>

[/php]

Well, the syntax highlighting should give at least some hints. The problem is two lines up from the indicated line:

[php]";[/php]

Change that to:

[php]";[/php]

Be sure to realize what that backslash does and how it affects not only the statement, but also the general control flow and ultimately your whole code.

Edit: Peg110 beat me to the punch :stuck_out_tongue:

Hey thanks alot!!

I think I should clean up the white up on that page makes things look better.

You wont belive how happy I am now, it’s taken ages to get it sorted :D.

Once again thanks for that.

Carl

Hey only me again,

Sorry for dpuble post but I’m having a few problems with the code displaying background images…

[php]<?php
If ($vbulletin->userinfo[‘userid’]!=0)
{
echo ’
<td style=“background-image:url(“http://www.battlestationextreme.com/images/homepage09.jpg”); height:40px”>






My BSE


  <tr> 
    <td style="background-image:url("http://www.battlestationextreme.com/images/homepage10.jpg"); height:29px"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table29"> 
        <tr> 
          <td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td> 
          <td width="92%"><a class="link1" href="http://www.battlestationextreme.com/forums/usercp.php">Register!</a></td> 
        </tr> 
      </table> 
    </td> 
  </tr> 
  <tr> 
    <td style="background-image:url("http://www.battlestationextreme.com/images/homepage10.jpg"); height:29px"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table30"> 
        <tr> 
          <td width="8%"><img src="http://www.battlestationextreme.com/images/spacer.gif" alt="" width="15" height="29"></td> 
          <td width="92%"><a class="link1" href="http://www.battlestationextreme.com/forums/private.php">Login</a></td> 
        </tr> 
       </table> 
     </td>'; 
} else { 
echo "Your not logged in so we display this"; 
} 

?>
[/php]

The background images in this code don’t show up on page for some reason… if you don’t mind taking a look for me please.

Carl

HTML problem. Check out the source code and pay special attention to usage of quotes (I’ve seen at least one point at which incorrect quotes are used).

Oh ok, could some one please help me out on that as I’m not sure.

Carl

I think you should look at the STYLE tag that you are using…

[php]

[/php]

I am not sure how well this style works by pointing to a URL. Rather I think it’s better to point it to a path on the server.

[php]

[/php]

As Zyppora also points out… Look out about the usage of your quotes. As you can see in the first iteration above, the double quotes are not quoting what you might think.

Hi,

Thanks to every one who has posted in this topic.

Carl

Sponsor our Newsletter | Privacy Policy | Terms of Service