PDA

View Full Version : More PHP help for the retard



bigperm
June 19th, 2001, 13:14
I want to have on page that if a url argument exists, it uses that to display the nessacary contents, but if it doesn't exist, I want it to display a certain paragraph or two of html...

Here is the code I dreamed up out of my head...

<html>

<head>

<title>Articles</title>
<link rel="StyleSheet" type="text/css" href="/~bigperm/inc/perm2.css">
</head>

<body>

<table border="0" width="100%" bgcolor="#d8d8d8" >
<tr>
<td bgcolor="#d8d8d8"><img src="/~bigperm/images/bigperm.jpg" width="468"
height="60"></td>
</tr>
<tr>
<!-- Top Navigation -->
<td bgcolor="#a0a0a0" align="center"><?php include "http://www.yupapa.com/~bigperm/inc/topnav.txt" ?></td>
</tr>
<tr>
<td><table border="0" width="100%" >
<tr>

<!-- Main Part -->
<td width="60%"><font size="3" face="verdana" >
<?php if $art=true require ('/usr/home/b/i/bigperm/public_html/art/$art.txt');
else printf " <h2>Articles</h2><br> <p>Writing articles lets me explain some things to people that would be harder to explain in person, or in a chat room. So, here are some articles for ya, about Capitalism and Communism. Coming Soon! Articles about building webpages!</p></font></p>" ?>
</td>
<td width="20%" bgcolor="#0000FF" valign="top">
<!-- Secondary Part -->

<?php
require("/usr/home/b/i/bigperm/public_html/inc/artnav.txt");
?>
</body>
</html></td>
</tr>
</table>
</td>
</tr>
<tr><!-- Footer -->
<td bgcolor="#0000FF" align="right"><?php include "http://www.yupapa.com/~bigperm/inc/footer.txt" ?></td>
</tr>
</table>
</body>
</html>

Does that make ANY sense to ANYBODY?

lucifer
June 19th, 2001, 13:55
<?php if ($art){
include "/usr/home/b/i/bigperm/public_html/art/$art.txt";
} else {
echo " <h2>Articles</h2><br> <p>...</p></font></p>";
} ?>



" not ' or $art will not get interpreted :(

if (condition){block} else{block}

include not require cos I think require will cause problems if $art is null or the file don't exist as require is always loaded
include is safer - I could be wrong

do you need the http: bits? are the files not local?



if you're giveing examples you can strip the html to the bare minimum ;)

bigperm
June 19th, 2001, 14:41
do you need the http: bits? are the files not local? That is residue of my early incompetence with php include. I thought you could use the relational path "/~bigperm/inc/file.ext" but when that didn't work, I just used the full url. I now know that I have to system path. Thanks for the help.

gyrbo
June 19th, 2001, 14:59
You're on a donhost reseller, hehe.

bigperm
June 19th, 2001, 20:14
Yupapa is awesome though... I have no complaints.

YUPAPA
June 19th, 2001, 22:00
?

system path = /home/b/i/bigperm/public_html

???

bigperm
June 20th, 2001, 12:07
??

gyrbo
June 20th, 2001, 15:20
Originally posted by YUPAPA
?

system path = /home/b/i/bigperm/public_html

???

That's how I saw it.

bigperm
June 20th, 2001, 18:56
Yeah, that's how I saw it too. I still have no idea what he means...

Also, I am getting this error:

Parse error: parse error, expecting `','' or `';'' in /usr/home/b/i/bigperm/public_html/mor/morons.php on line 34

What does that mean?

lucifer
June 20th, 2001, 19:03
It means it's f****d.

proberbly wants a ; or a ,

you'll have to show some code to be more use.


make sure you have a ; after each instruction even if it's at the end of a block or the script ie before } or ?>

could be on a line earlier check all your strings are terminated (matching quotes)


commenting out different bits using # or // will help you track down the dodgy line

bigperm
June 20th, 2001, 19:10
<?php if ($moronid){
include "/usr/home/b/i/bigperm/public_html/art/$art.txt";
} else {
echo " <h2>Morons</h2><br> Lot's of HTML </p>" ; } ?>

The last line is the one I am getting the error message on

lucifer
June 20th, 2001, 19:14
you could try
if (!empty($moronid)){.....

otherwise check the include and the echo work ok on there own without all the if stuff

lucifer
June 21st, 2001, 04:44
works for me (both ways)

your html is a mess though

at least 2 </html> which won't help


is the error
Warning: Failed opening '/usr/home/b/i/bigperm/public_html/art/.txt' for inclusion (include_path='') in ...

if so it's about the include file not your code.

you will want to add some error checking to make sure $art is valid