Jump to content

php and html display errors


Thrice01

Recommended Posts

new here, hoping to use this forum more often though.

ok so my website worked on localhost fine, v4.something. I transferred to my server which is running v5.1.3 and i noticed something.

I have a bunch of if statements that determine what table gets displayed. Something like..

<?php
if ($pagename == 'login.php') { ?>
<table border="0" align="center">
<tr>
<td>This gets displayer</td>
</tr>
</table>
<?
} else {
[i]do somethign else[/i]
}
?>

Ok, that does not work at all. The only way i can get it to work is by echoing the table and placing slashes (\) infront of the quote marks. e.g.

<?php
if ($pagename == 'login.php') {
echo "
<table border=\"0\" align=\"center\">
<tr>
<td>This gets displayer</td>
</tr>
</table>
";

} else {
[i]do somethign else[/i]
}
?>

Any explaintation why it won't let me code it the first way? im really not keen on echoing all my html data
Link to comment
Share on other sites

You have short opening PHP tag your server may not be configured to use <? as a opening php tag. So try this instead:
[code]<?php
if ($pagename == 'login.php') { ?>
<table border="0" align="center">
<tr>
<td>This gets displayer</td>
</tr>
</table>
<?php
} else {
    //do somethign else
}
?>[/code]
Link to comment
Share on other sites

[!--quoteo(post=385453:date=Jun 19 2006, 12:09 AM:name=Thrice01)--][div class=\'quotetop\']QUOTE(Thrice01 @ Jun 19 2006, 12:09 AM) [snapback]385453[/snapback][/div][div class=\'quotemain\'][!--quotec--]
new here, hoping to use this forum more often though.

ok so my website worked on localhost fine, v4.something. I transferred to my server which is running v5.1.3 and i noticed something.

I have a bunch of if statements that determine what table gets displayed. Something like..

<?php
if ($pagename == 'login.php') { ?>
<table border="0" align="center">
<tr>
<td>This gets displayer</td>
</tr>
</table>
<?
} else {
[i]do somethign else[/i]
}
?>

Ok, that does not work at all. The only way i can get it to work is by echoing the table and placing slashes (\) infront of the quote marks. e.g.

<?php
if ($pagename == 'login.php') {
echo "
<table border=\"0\" align=\"center\">
<tr>
<td>This gets displayer</td>
</tr>
</table>
";

} else {
[i]do somethign else[/i]
}
?>

Any explaintation why it won't let me code it the first way? im really not keen on echoing all my html data
[/quote]

You cant use " when you user echo you must replace them with ' .

ie.
[code]
<?php
if ($pagename == 'login.php') {
echo ("
  <table border='0' align='center'>
   <tr>
     <td>This gets displayer</td>
   </tr>
  </table>
");

} else {
  [i]do somethign else[/i]
}
?>
[/code]
Link to comment
Share on other sites

[!--quoteo(post=385561:date=Jun 19 2006, 09:17 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 19 2006, 09:17 PM) [snapback]385561[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You have short opening PHP tag your server may not be configured to use <? as a opening php tag. So try this instead:
[code]<?php
if ($pagename == 'login.php') { ?>
<table border="0" align="center">
<tr>
<td>This gets displayer</td>
</tr>
</table>
<?php
} else {
    //do somethign else
}
?>[/code]
[/quote]

i replaced all <? in my code with <?php. Still doesn't work. When i ran the page, the php code was output as html text for some reason. It's like the page is not reading php at all, yet it works fine on another couple of pages.

Any ideas?
Link to comment
Share on other sites

[!--quoteo(post=385841:date=Jun 20 2006, 12:30 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 20 2006, 12:30 PM) [snapback]385841[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Post you actual code.
[/quote]

can't, it's work related.


[!--quoteo(post=385858:date=Jun 20 2006, 02:08 PM:name=mainewoods)--][div class=\'quotetop\']QUOTE(mainewoods @ Jun 20 2006, 02:08 PM) [snapback]385858[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Sound like your php parser is not running. Try creating the simplist possible page:
[code]<?php
    echo "hello world";
?>[/code]
If that doen't work then your php parser is not working.
[/quote]
ill give that a shot when im back in the office.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.