PDA

View Full Version : Newbie going crazy. HEEEEEEELP!!


swallow
08-27-2002, 07:00 PM
I am trying to install a guestbook on my site. I found this php book which I liked and started to install it. My webpages are three columns and I tried to insert the php code in the middle column. It loads bout stops there. Take a look.



http://www.dingliswallows.com/testing/guestbook.php

A normal page looks like this:

http://www.dingliswallows.com/news/02_03/signings.php

It seems that the right and bottom content is not being included, icidently they are php includes as well.

Could someone enlighten me? Does the code start to loop?

Help would be appreciated.

The Wizzard
08-27-2002, 07:08 PM
Post your code please.

swallow
08-27-2002, 07:11 PM
Sorry I forgot. This is the php code that I included.

<?php

echo "<title>Widgy Guestbook</title>";

if (($REQUEST_METHOD=='POST'))
{
// Date Stamp
$datestamp = date("D M d, Y H:i:s");
$fpn=@fopen("guestbook.txt","a+");
@flock ($fpn,2);

// ***********************************IP Checking
$ipentry = $REMOTE_ADDR;

// ***********************************Remove HTML tags
$txtcomments = ereg_replace("<","&lt;",$txtcomments);
$txtcomments = ereg_replace(">","&gt;",$txtcomments);

// ***********************************Smileys
$txtcomments = str_replace (":-)", "<img src=\"smile.gif\">", $txtcomments);
$txtcomments = str_replace (":-(", "<img src=\"frown.gif\">", $txtcomments);
$txtcomments = str_replace (";-)", "<img src=\"wink.gif\">", $txtcomments);
$txtcomments = str_replace (":D", "<img src=\"biggrin.gif\">", $txtcomments);
$txtcomments = str_replace ("8-)", "<img src=\"cool.gif\">", $txtcomments);

// ***********************************Remove HTML
$txtname = strip_tags($txtname);
$txtname = StripSlashes($txtname);
$txtemail= strip_tags($txtemail);

//************************************Remove back slashes
$txtcomments = stripslashes($txtcomments);

//************************************Allow line breaks
$txtcomments = ereg_replace("(\r\n|\n|\r)", "<br />",$txtcomments);

//************************************ICQ image
$img = "<img src=\"http://wwp.icq.com/scripts/online.dll?icq=$icq&img=5\" alt=\"$icq\">";

//************************************Output
$rec = "<table border=\"0\" width=\"425\"><tr><td width=\"64\">Name: </td><td width=\"361\"><b>$txtname</b></td></tr><tr><td width=\"15%\">Email: </td><td width=\"85%\"><b><u><a href=\"mailto:$txtemail\">$txtemail</a></u></b></td></tr><tr><td width=\"15%\">Website: </td><td width=\"85%\"><b><u><a href=\"$txtwebsite\" target=\"_blank\">$txtwebsite</a></u></b></td></tr><tr><td width=\"15%\" valign=\"top\">Comments: </td><td width=\"85%\"><b>$txtcomments</b></td></tr></table><br><i><small>Posted on: $datestamp<br><small>IP Address: $ipentry</small></small></i><br><br><hr size=\"2\" noshade color=\"#000099\" width=\"400\">". "\n";

$fw=fwrite($fpn,$rec);
@flock($fpn,3);
@fclose($fpn);

}

$fp=@fopen("guestbook.txt","r"); // r = read
@flock ($fp,2);
$arrr=array();

while ($line=@fgets($fp,4096))
{
array_push($arrr,$line);
}

$totalent=count($arrr);

if ($totalent<0)
{
$totalent=0;
}

print "<small><a href=\"guest.htm\">Sign The Guestbook</a></small><br>";
print "<small>Total Guestbook Entries = $totalent</small><br><br>";

if (count($arrr)==0)
{
print "<br><br><b>_=: No Guestbook Entrys :=_</b>";
exit();
}

$ar=array_reverse($arrr);
$arrr=array();

$highlimit=$totalent;
for($i=0;$i<=$highlimit;$i++)
{
if (!$ar[$i])
{
exit;
}

print "$ar[$i]";
print "<br>";

}

@flock($fp,3);
@fclose($fp);
php?>

The Wizzard
08-27-2002, 11:51 PM
And so the problem is the page is not including your footer file?

Could you please post the entire code to that page.

Thanks. Im sure there is an "If" that isnt being closed somewhere or something.

swallow
08-28-2002, 06:33 AM
Actually the page is not including the right hand include or the footer file. I took away the right hand and footer includes and put in text on the right. This is still not showing. There is something wrong with the formatting as well. Thanks for your interest.

Here is the code for the entire page:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-uk">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">

<title>dingliswallows.com</title>
<base target="main">
<style>
<!--

/*
Text Link Underline Remover Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

a{text-decoration:none}
//-->
</style>
<style fprolloverstyle>A:hover {color: #DD0000; font-size: 10pt; font-family: Arial}
</style>

</head>

<body link="#000099" vlink="#0000FF" topmargin="0" leftmargin="0" alink="#DD0000" text="#000000" style="font-family: Arial; font-size: 10pt">

<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// -->
</script>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="760" height="300">
<tr>
<center>
<td valign="top" width="152" height="242">

<?include '../includeleft.html';?>

</td>
<td width="6"></td>
</center>
<td width="435" valign="top" align="center" height="300">
&nbsp;
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="425">
<tr>
<td height="26" bgcolor="#DD0000" colspan="2" width="425">
<p style="margin-left: 5"><b><font color="#FFFFFF" face="Arial" size="2">Guest
Book </font></b>
</td>
</tr>
<tr>
<td height="26" align="center" colspan="2" width="425" valign="top">
<p>&nbsp;
<p>
<?php

echo "<title>Widgy Guestbook</title>";

if (($REQUEST_METHOD=='POST'))
{
// Date Stamp
$datestamp = date("D M d, Y H:i:s");
$fpn=@fopen("guestbook.txt","a+");
@flock ($fpn,2);

// ***********************************IP Checking
$ipentry = $REMOTE_ADDR;

// ***********************************Remove HTML tags
$txtcomments = ereg_replace("<","&lt;",$txtcomments);
$txtcomments = ereg_replace(">","&gt;",$txtcomments);

// ***********************************Smileys
$txtcomments = str_replace (":-)", "<img src=\"smile.gif\">", $txtcomments);
$txtcomments = str_replace (":-(", "<img src=\"frown.gif\">", $txtcomments);
$txtcomments = str_replace (";-)", "<img src=\"wink.gif\">", $txtcomments);
$txtcomments = str_replace (":D", "<img src=\"biggrin.gif\">", $txtcomments);
$txtcomments = str_replace ("8-)", "<img src=\"cool.gif\">", $txtcomments);

// ***********************************Remove HTML
$txtname = strip_tags($txtname);
$txtname = StripSlashes($txtname);
$txtemail= strip_tags($txtemail);

//************************************Remove back slashes
$txtcomments = stripslashes($txtcomments);

//************************************Allow line breaks
$txtcomments = ereg_replace("(\r\n|\n|\r)", "<br />",$txtcomments);

//************************************ICQ image
$img = "<img src=\"http://wwp.icq.com/scripts/online.dll?icq=$icq&img=5\" alt=\"$icq\">";

//************************************Output
$rec = "<table border=\"0\" width=\"425\"><tr><td width=\"64\">Name: </td><td width=\"361\"><b>$txtname</b></td></tr><tr><td width=\"15%\">Email: </td><td width=\"85%\"><b><u><a href=\"mailto:$txtemail\">$txtemail</a></u></b></td></tr><tr><td width=\"15%\">Website: </td><td width=\"85%\"><b><u><a href=\"$txtwebsite\" target=\"_blank\">$txtwebsite</a></u></b></td></tr><tr><td width=\"15%\" valign=\"top\">Comments: </td><td width=\"85%\"><b>$txtcomments</b></td></tr></table><br><i><small>Posted on: $datestamp<br><small>IP Address: $ipentry</small></small></i><br><br><hr size=\"2\" noshade color=\"#000099\" width=\"400\">". "\n";

$fw=fwrite($fpn,$rec);
@flock($fpn,3);
@fclose($fpn);

}

$fp=@fopen("guestbook.txt","r"); // r = read
@flock ($fp,2);
$arrr=array();

while ($line=@fgets($fp,4096))
{
array_push($arrr,$line);
}

$totalent=count($arrr);

if ($totalent<0)
{
$totalent=0;
}

print "<small><a href=\"guest.htm\">Sign The Guestbook</a></small><br>";
print "<small>Total Guestbook Entries = $totalent</small><br><br>";

if (count($arrr)==0)
{
print "<br><br><b>_=: No Guestbook Entrys :=_</b>";
exit();
}

$ar=array_reverse($arrr);
$arrr=array();

$highlimit=$totalent;
for($i=0;$i<=$highlimit;$i++)
{
if (!$ar[$i])
{
exit;
}

print "$ar[$i]";
print "<br>";

}

@flock($fp,3);
@fclose($fp);
?>
</td>
</tr>
</table>
<p>&nbsp;</p>
</center>
</div>
</td>
<center>
<td width="5"></td>
</center>
<td valign="top" width="152">Is this going to work? I hope so.</td>
</tr>
</table>
</div>

<hr color="#000099" size="3">
<p>This is another test.</p>
</body>

</html>

#####Here is the code for the form. It is an html file whcih should be easy to modify according to the normal set up. :confused:

Actually one thing that I tried was to include the text file instead. This works fine as far as loading the page is concerned. However, when a new entry is added to the form the action looks to execute something. Can this be changed so that the action executes the php code and then loads the guestbook with included text?

The Wizzard
08-28-2002, 05:24 PM
Well, I dont even see your includes for the right and footer file...

Try this...


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-uk">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">

<title>dingliswallows.com</title>
<base target="main">
<style>
<!--

/*
Text Link Underline Remover Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

a{text-decoration:none}
//-->
</style>
<style fprolloverstyle>A:hover {color: #DD0000; font-size: 10pt; font-family: Arial}
</style>

</head>

<body link="#000099" vlink="#0000FF" topmargin="0" leftmargin="0" alink="#DD0000" text="#000000" style="font-family: Arial; font-size: 10pt">

<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// -->
</script>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="760" height="300">
<tr>
<center>
<td valign="top" width="152" height="242">

<?php

include ("../includeleft.html");

?>
<?php

include ("../right.html");

?>

</td>
<td width="6"></td>
</center>
<td width="435" valign="top" align="center" height="300">

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="425">
<tr>
<td height="26" bgcolor="#DD0000" colspan="2" width="425">
<p style="margin-left: 5"><b><font color="#FFFFFF" face="Arial" size="2">Guest
Book </font></b>
</td>
</tr>
<tr>
<td height="26" align="center" colspan="2" width="425" valign="top">
<p>
<p>
<?php

echo "<title>Widgy Guestbook</title>";

if (($REQUEST_METHOD=='POST'))
{
// Date Stamp
$datestamp = date("D M d, Y H:i:s");
$fpn=@fopen("guestbook.txt","a+");
@flock ($fpn,2);

// ***********************************IP Checking
$ipentry = $REMOTE_ADDR;

// ***********************************Remove HTML tags
$txtcomments = ereg_replace("<","&lt;",$txtcomments);
$txtcomments = ereg_replace(">","&gt;",$txtcomments);

// ***********************************Smileys
$txtcomments = str_replace (":-)", "<img src=\"smile.gif\">", $txtcomments);
$txtcomments = str_replace (":-(", "<img src=\"frown.gif\">", $txtcomments);
$txtcomments = str_replace (";-)", "<img src=\"wink.gif\">", $txtcomments);
$txtcomments = str_replace ("", "<img src=\"biggrin.gif\">", $txtcomments);
$txtcomments = str_replace ("8-)", "<img src=\"cool.gif\">", $txtcomments);

// ***********************************Remove HTML
$txtname = strip_tags($txtname);
$txtname = StripSlashes($txtname);
$txtemail= strip_tags($txtemail);

//************************************Remove back slashes
$txtcomments = stripslashes($txtcomments);

//************************************Allow line breaks
$txtcomments = ereg_replace("(\r\n|\n|\r)", "<br />",$txtcomments);

//************************************ICQ image
$img = "<img src=\"http://wwp.icq.com/scripts/online.dll?icq=$icq&img=5\" alt=\"$icq\">";

//************************************Output
$rec = "<table border=\"0\" width=\"425\"><tr><td width=\"64\">Name: </td><td width=\"361\"><b>$txtname</b></td></tr><tr><td width=\"15%\">Email: </td><td width=\"85%\"><b><u><a href=\"mailto:$txtemail\">$txtemail</a></u></b></td></tr><tr><td width=\"15%\">Website: </td><td width=\"85%\"><b><u><a href=\"$txtwebsite\" target=\"_blank\">$txtwebsite</a></u></b></td></tr><tr><td width=\"15%\" valign=\"top\">Comments: </td><td width=\"85%\"><b>$txtcomments</b></td></tr></table><br><i><small>Posted on: $datestamp<br><small>IP Address: $ipentry</small></small></i><br><br><hr size=\"2\" noshade color=\"#000099\" width=\"400\">". "\n";

$fw=fwrite($fpn,$rec);
@flock($fpn,3);
@fclose($fpn);

}

$fp=@fopen("guestbook.txt","r"); // r = read
@flock ($fp,2);
$arrr=array();

while ($line=@fgets($fp,4096))
{
array_push($arrr,$line);
}

$totalent=count($arrr);

if ($totalent<0)
{
$totalent=0;
}

print "<small><a href=\"guest.htm\">Sign The Guestbook</a></small><br>";
print "<small>Total Guestbook Entries = $totalent</small><br><br>";

if (count($arrr)==0)
{
print "<br><br><b>_=: No Guestbook Entrys :=_</b>";
exit();
}

$ar=array_reverse($arrr);
$arrr=array();

$highlimit=$totalent;
for($i=0;$i<=$highlimit;$i++)
{
if (!$ar[$i])
{
exit;
}

print "$ar[$i]";
print "<br>";

}

@flock($fp,3);
@fclose($fp);
?>
</td>
</tr>
</table>
<p> </p>
</center>
</div>
</td>
<center>
<td width="5"></td>
</center>
<td valign="top" width="152">Is this going to work? I hope so.</td>
</tr>
</table>
</div>

<hr color="#000099" size="3">
<p>This is another test.</p>
<?php

include ("../footer.html");

?>

</body>

</html>




Now, im not sure on this, but I know with Server Side Includes the file extension must be .asp or .shtml so im not sure if with a php include if the file extension must be .php If the above doesnt work, try to rename the files with a .php extension, or .inc

Good Luck!

swallow
08-28-2002, 07:16 PM
Thanks Wizzard. I shall try that out. The reason you did not see the right hand side and footer includes is that I took them out and put some plain text on teh right to see if it was the includes taht was causing the problem. The<?php '..includeright';?> should go where there is "This is another test."