Jump to content

Archived

This topic is now archived and is closed to further replies.

Thrice01

php and html display errors

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

Share this post


Link to post
Share on other sites
What do you mean by doesn't work? Does it just display the html wether or not the if statement was satified? What?

Share this post


Link to post
Share on other sites
it displays nothing at all. A blank screen.

IF i echo out the table, the table shows up fine.

Share this post


Link to post
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]

Share this post


Link to post
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]

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
Post you actual code.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.