PDA

Click to See Complete Forum and Search --> : HELP! unexpected T_LNUMBER


hlstriker
Dec 22nd, 2005, 11:32 AM
Hi, when I try and run some code if gives me this error...

Parse error: parse error, unexpected T_LNUMBER in added.php on line 4

Here is the php code i'm using...

<?php
$da = getdate();
$date="$da[weekday] $da[mday] $da[month] $da[year]";
$news = ("<table border="0" width="94%" id="table10" cellspacing="0" cellpadding="0"

height="136">
<tr>
<td valign="top" height="15" width="10">
<img border="0" src="images/navs/tlc.gif" width="10" height="15">
</td>
<td valign="top" height="15" background="images/navs/tm.gif">
</td><td valign="top" height="15" width="10">
<img border="0" src="images/navs/trc.gif" width="10" height="15">
</td>
</tr><tr>
<td valign="top" width="10" background="images/navs/tlt.gif">
</td>
<td valign="top">
<table border="3" width="100%" id="table11" cellspacing="0" cellpadding="0"

height="100%" bordercolordark="#222931" bordercolorlight="#413F52">
<tr>
<td height="26" background="images/navs/toptblbg.gif">
<div align="center">
<table border="0" width="98%" id="table14" cellspacing="0" cellpadding="0">
<tr>
<td width="189">
<b>
<font face="Arial" size="2">$title</font></b></td>
<td align="right">
<b>
<font face="Arial" size="2">$date</font></b></td>
</tr>
</table></div>
</td>
</tr><tr>
<td valign="top">$news</td></tr>
<tr>
<td height="24" background="images/navs/toptblbg.gif">
<div align="center">
<table border="0" width="98%" id="table15" cellspacing="0" cellpadding="0">
<tr>
<td><b>
<font face="Arial" size="2">Posted by $posted</font></b></td>
</tr>
</table>
</div>
</td></tr>
</table>
</td>
<td valign="top" width="10" background="images/navs/trt.gif"></td>
</tr>
<tr>
<td valign="top" height="12" width="10">
<img border="0" src="images/navs/blc.gif" width="10" height="12"></td>
<td valign="top" height="12" background="images/navs/btm.gif"></td>
<td valign="top" height="12" width="10">
<img border="0" src="images/navs/brc.gif" width="10" height="12"></td>
</tr>
</table>
<br>");

$file = fopen("news.php", "r");
$read = fread($file, filesize("news.php"));
fclose($file);
$blah = fopen("news.php", "w");
$news=stripslashes($news);
fwrite($blah, "$news $read");
fclose ($blah);
print "<meta http-equiv=\"refresh\"

content=\"1;http://mywebsite.com/\">";
?>

I think I need to do something to that html in the variable? Please help!

Thanks in advance :)

neicedover1982
Dec 22nd, 2005, 01:10 PM
$news = ("<table border="0" width="94%"

I would remove the ( mark and then take out all the quotes and make the either ' (single quotes) or no quote at all. When I am setting HTML into variables, I use a single ' mark because PHP sees each " as a start and end point.


<?php
$da = getdate();
$date="$da[weekday] $da[mday] $da[month] $da[year]";
$news = "<table border='0' width='94%' id='table10' cellspacing='0' cellpadding='0'

height='136'>
<tr>
<td valign='top' height='15' width='10'>
<img border='0' src='images/navs/tlc.gif' width='10' height='15'>
</td>
<td valign='top' height='15' background='images/navs/tm.gif'>
</td><td valign='top' height='15' width='10'>
<img border='0' src='images/navs/trc.gif' width='10' height='15'>
</td>
</tr><tr>
<td valign='top' width='10' background='images/navs/tlt.gif'>
</td>
<td valign='top'>
<table border='3' width='100%' id='table11' cellspacing='0' cellpadding='0'

height='100%' bordercolordark='#222931' bordercolorlight='#413F52'>
<tr>
<td height='26' background='images/navs/toptblbg.gif'>
<div align='center'>
<table border='0' width='98%' id='table14' cellspacing='0' cellpadding='0'>
<tr>
<td width='189'>
<b>
<font face='Arial' size='2'>$title</font></b></td>
<td align='right'>
<b>
<font face='Arial' size='2'>$date</font></b></td>
</tr>
</table></div>
</td>
</tr><tr>
<td valign='top'>$news</td></tr>
<tr>
<td height='24' background='images/navs/toptblbg.gif'>
<div align='center'>
<table border='0' width='98%' id='table15' cellspacing='0' cellpadding='0'>
<tr>
<td><b>
<font face='Arial' size='2'>Posted by $posted</font></b></td>
</tr>
</table>
</div>
</td></tr>
</table>
</td>
<td valign='top' width='10' background='images/navs/trt.gif'></td>
</tr>
<tr>
<td valign='top' height='12' width='10'>
<img border='0' src='images/navs/blc.gif' width='10' height='12'></td>
<td valign='top' height='12' background='images/navs/btm.gif'></td>
<td valign='top' height='12' width='10'>
<img border='0' src='images/navs/brc.gif' width='10' height='12'></td>
</tr>
</table>
<br>";

echo $news;
?>

I used this and it worked fine

CornedBee
Dec 23rd, 2005, 07:50 AM
Actually, it's a stupid idea in the first place to put all the HTML code into a PHP string. Aside from the quote issue, it also probably hinders syntax highlighting.
Then it's not a particularly good idea to modify a PHP file from a script. You can get permission problems with that, and it's unsafe, too. If you have to write a static file, at least give it a html extension.
That said, I see nothing wrong with dynamically generating the file. Unless you don't have a database available. In which case it would still be better to write the news entries into a terse XML file and process and output that instead. (XSLT processing is an option.)

If you HAVE to do it your way, at least use HEREDOC syntax for the string:
$news = <<END
<table> ...
</table>
END;

Do I even need to comment on how horribly 1992 your HTML is?

hlstriker
Dec 25th, 2005, 10:29 AM
Hey! Don't blame me, blame FrontPage :D!

I never really spent much time learning HTML. How would you make HTML up to date though? lol

or.. Can you make websites intirely from PHP, no HTML needed?

CornedBee
Dec 25th, 2005, 01:13 PM
I blame you for using FrontPage. :)

No, PHP always has to emit HTML (or something else that the browser can interpret, but HTML is the best supported.)
But the point is that you should learn HTML and CSS. Then you can code it properly. By hand.