Jump to content


Photo

php and html display errors


  • Please log in to reply
8 replies to this topic

#1 Thrice01

Thrice01
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 June 2006 - 11:09 PM

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 {
do somethign else
}
?>

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 {
do somethign else
}
?>

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

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 18 June 2006 - 11:16 PM

What do you mean by doesn't work? Does it just display the html wether or not the if statement was satified? What?

#3 Thrice01

Thrice01
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 June 2006 - 11:20 PM

it displays nothing at all. A blank screen.

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

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 June 2006 - 09:17 AM

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


#5 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 19 June 2006 - 09:41 AM

[!--quoteo(post=385453:date=Jun 19 2006, 12:09 AM:name=Thrice01)--][div class=\'quotetop\']QUOTE(Thrice01 @ Jun 19 2006, 12:09 AM) View Post[/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 {
do somethign else
}
?>

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 {
do somethign else
}
?>

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.
<?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]
}
?>

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#6 Thrice01

Thrice01
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 June 2006 - 11:20 PM

[!--quoteo(post=385561:date=Jun 19 2006, 09:17 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 19 2006, 09:17 PM) View Post[/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:
<?php
if ($pagename == 'login.php') { ?>
<table border="0" align="center">
<tr>
<td>This gets displayer</td>
</tr>
</table>
<?php
} else {
    //do somethign else
}
?>
[/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?

#7 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 20 June 2006 - 12:30 AM

Post you actual code.

#8 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 20 June 2006 - 02:08 AM

Sound like your php parser is not running. Try creating the simplist possible page:
<?php
    echo "hello world";
?>
If that doen't work then your php parser is not working.

#9 Thrice01

Thrice01
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 21 June 2006 - 01:19 AM

[!--quoteo(post=385841:date=Jun 20 2006, 12:30 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 20 2006, 12:30 PM) View Post[/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) View Post[/div][div class=\'quotemain\'][!--quotec--]
Sound like your php parser is not running. Try creating the simplist possible page:
<?php
    echo "hello world";
?>
If that doen't work then your php parser is not working.
[/quote]
ill give that a shot when im back in the office.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users