PDA

View Full Version : White stripes


Redcap
01-22-2006, 04:38 PM
If i include a php document, i get white stripes all over my layout
Here is a screenie (http://img6.imageshack.us/img6/2258/screen7yq.jpg)
And this is the code:
<html>
<head>
<title>Layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table id="Table_01" width="1000" height="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<img src="images/Layout_01.jpg" width="1000" height="124" alt=""></td>
</tr>
<tr>
<td rowspan="2">
<img src="images/Layout_02.jpg" width="753" height="676" alt=""></td>
<td>
<?
include 'shoutbox.php'
?>
<img src="images/Shoutbox.jpg" width="130" height="268" alt=""></td>
<td rowspan="2">
<img src="images/Layout_04.jpg" width="117" height="676" alt=""></td>
</tr>
<tr>
<td>
<img src="images/Layout_05.jpg" width="130" height="408" alt=""></td>
</tr>
</table>
</body>
</html>

Does anybody knows how i get the white stripes away?
Thanks

Shoutbox.php too:
<script type="text/javascript">
<!--
function addsmiley(code) {
var pretext = document.forms['shoutbox_form'].shoutbox_message.value;
this.code = code;
document.forms['shoutbox_form'].shoutbox_message.value = pretext + code;
}
//-->
</script>

<style type="text/css">



div.shoutbox {
background: #1A5209;
padding: 5px;
width: 190px;
height: 200px;
border: 1px solid #000000;
overflow: auto;
color: #7D813F;
font: normal 10px verdana,tahoma,arial }

img.smileys {
border: 0;
cursor: pointer; }


#shoutbox-message { width: 200px }
strong {
color: #7D813F;
font: bold 10px verdana,tahoma,arial }


ul {
margin: 0;
padding: 0;
list-style-type: none;
color: #DA2032;
font: normal 10px verdana,tahoma,arial; }


input {
border: 1px solid #000000;
background-color: #1A5209
color: #1A5209;
font: normal 10px verdana,tahoma,arial; }

textarea {
width: 195px;
padding: 0px;
border: 1px solid #000000;
background-color: #1A5209;
color: #1A5209;
font: normal 10px verdana,tahoma,arial; }

</style>

<?php
include("config.php");
if ($_POST['shoutbox_submit']) {
$name = $_POST['shoutbox_name'];
$ip = $_POST['shoutbox_ip'];
$message = $_POST['shoutbox_message'];
$mlen = strlen($message);
$date = date("F jS Y");
if ($name == "") {
echo "<strong>Error: Please enter your nickname.</strong>";
}
else if ($message == "") {
echo "<strong>Error: No message to be sent.</strong>";
}
else if ($mlen > $max_length) {
echo "<strong>Error: Message too long.</strong>";
}
else {
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name) or die("Cannot connect to database");
mysql_query("INSERT INTO shoutbox(name,ip,message,date) VALUES('$name','$ip','$message','$date')");
mysql_close($db);
}
}
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name) or die("Cannot connect to database");
$query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT $dmessage";
$result = mysql_query($query);
echo "<div class=\"shoutbox\">\n";
echo "<ul>\n";
while($r=mysql_fetch_array($result)) {
//Strips unwanted HTML from nickname
$name = $r['name'];
$name = strip_tags($name);
//Strips unwanted HTML from message
$message = $r['message'];
$message = strip_tags($message);
// Transform text to smileys =)
$message = str_replace("=(","<img src=\"smileys/sad.gif\" alt=\"=(\"/>", $message);
$message = str_replace(":(","<img src=\"smileys/sad.gif\" alt=\":(\"/>", $message);
$message = str_replace(";(","<img src=\"smileys/cry.gif\" alt=\";(\"/>", $message);
$message = str_replace(":@","<img src=\"smileys/mad.gif\" alt=\":@\"/>", $message);
$message = ereg_replace(":)","<img src=\"smileys/smile.gif\" alt=\":)\"/>", $message);
$message = ereg_replace("=)","<img src=\"smileys/smile.gif\" alt=\"=)\"/>", $message);
$message = ereg_replace(":D","<img src=\"smileys/laugh.gif\" alt=\":D\"/>", $message);
$message = ereg_replace(":d","<img src=\"smileys/laugh.gif\" alt=\":d\"/>", $message);
$message = ereg_replace(":p","<img src=\"smileys/tongue.gif\" alt=\":p\"/>", $message);
$message = ereg_replace(":P","<img src=\"smileys/tongue.gif\" alt=\":P\"/>", $message);
$message = ereg_replace(":O","<img src=\"smileys/shocked.gif\" alt=\":O\"/>", $message);
$message = ereg_replace(":o","<img src=\"smileys/shocked.gif\" alt=\":o\"/>", $message);
$message = ereg_replace(";)","<img src=\"smileys/wink.gif\" alt=\";)\"/>", $message);
$message = ereg_replace(":S","<img src=\"smileys/sick.gif\" alt=\":S\"/>", $message);
$message = ereg_replace(":s","<img src=\"smileys/sick.gif\" alt=\":s\"/>", $message);
$message = ereg_replace(":roll:","<img src=\"smileys/roll.gif\" alt=\":roll:\"/>", $message);
echo "<li title=\"Shouted on $r[date]\" style=\"cursor: pointer\"><strong>$name</strong>: $message</li>\n";
}
echo "</ul>\n";
echo "</div>\n";
mysql_close($db);
?>

<div>
<form id="shoutbox_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<strong>Nickname:</strong><br/>
<input type="text" name="shoutbox_name" size="37" maxlength="20"><br/>
<strong>Message:</strong><br/>
<img class="smileys" src="smileys/smile.gif" alt=":)" onclick="addsmiley(':)')"/>
<img class="smileys" src="smileys/laugh.gif" alt=":D" onclick="addsmiley(':D')"/>
<img class="smileys" src="smileys/wink.gif" alt=";)" onclick="addsmiley(';)')"/>
<img class="smileys" src="smileys/sad.gif" alt=":(" onclick="addsmiley(':(')"/>
<img class="smileys" src="smileys/shocked.gif" alt=":O" onclick="addsmiley(':O')"/>
<img class="smileys" src="smileys/tongue.gif" alt=":P" onclick="addsmiley(':P')"/>
<img class="smileys" src="smileys/sick.gif" alt=":S" onclick="addsmiley(':S')"/>
<img class="smileys" src="smileys/roll.gif" alt=":roll:" onclick="addsmiley(':roll:')"/>
<img class="smileys" src="smileys/cry.gif" alt=";(" onclick="addsmiley(';(')"/>
<img class="smileys" src="smileys/mad.gif" alt=":@" onclick="addsmiley(':@')"/><br/>
<textarea id="shoutbox-message" cols="20" rows="3" name="shoutbox_message"></textarea><br/>
<input type="submit" name="shoutbox_submit" value="Voeg toe!"></div>&nbsp;
<input type="hidden" name="shoutbox_ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
</form>
</div>

--------------------------------------------------------------------------------
Last edited by Redcap : Today at 12:25 PM.

Pennimus
01-22-2006, 05:01 PM
Well, your include statement is written wrongly. Try this and see if makes any difference


<?php include('shoutbox.php'); ?>


Another issue is that as shoutbox.php contains javascripts and CSS, you will end up with code that should be in the <head> of your document in the middle of the <body> - ill advised at the best of times.

- Adam

Redcap
01-23-2006, 03:25 PM
<?php include('shoutbox.php'); ?>
Doesn't work :(
And i don't know really what you mean with putting it in the middle of the body...
It doesn't matters where i put it, it always gets white stripes behind him

Pennimus
01-23-2006, 04:06 PM
Can we see a version of the page live?

What I mean about having things in the middle of the body is that currently you are trying to include the file shoutbox.php between your <body></body> tags.

However shoutbox.php contains style and javascript code that should always appear within the <head></head> tags.

Consequently when shoutbox.php is included by the server, you will have invalid code.

Not that I think that is causing the stripes, it was just an observation.

Redcap
01-23-2006, 04:25 PM
No, i don't have a server to put it on yet, just for now it's on my localhost. But i maked another screenie of when i put it in the <head>, it looks like this (http://img513.imageshack.us/img513/2491/head1hd.jpg)...
I've been working on it for 3 hours or something and i still don't know how to fix it :(

Redcap
01-24-2006, 01:23 PM
Anyone plz? I rly need this!

Pennimus
01-25-2006, 12:31 AM
Do you actually have PHP installed on your localhost?

You can't just put the shoutbox.php include in the head. The point is that shoutbox.php includes some elements that should go in the head, and some that should go in the body.

As such it isn't going to work the way you are trying it anyway... but regardless, I suspect you haven't got PHP installed, since the include code I gave you before is the correct way to include a file. If it didn't work, then something at your end has gone wrong.

jackle
01-25-2006, 01:27 AM
He wount have php installed on his local computer, best thing to do mate is to get some cheap or free webspace and check it then but make sure they have php otherwise it's useless and your page will come out wrong.

It's like an emulated game that renders wrong because of some code get some free space that has php and then check it out ;)

singedpiper
01-25-2006, 05:38 AM
oh, bother, I thought this was a post about horrible popular music

slushy77
01-29-2006, 03:07 AM
Hi Redcap,
(apologies if this gets posted twice - blasted enter keys)
There are several things that could cause your white stripes. Some of them might not be relevant for this part of the forum but here goes.

1)Server Load. looking at your php, there is quite a lot that isnt php. when a php file is requested, the php-module on the server must decide whether each line is interesting and how to process it. consider moving css and js into seperate files, which can then be cached by the client. Also consider seperating html and php e.g
<?php
include('layout.html');
//do the stuff with smileys
//..
include ('layout2.html'); ?>

You could use javascript to validate data, and remove undesirable code before it is sent to the server. At the moment validating is done server side, and undesirable code is being removed after retrieval(security risk).
Remove any superflous whitespace e.g echo ".....\n";

2)Database load. Select * from table puts a huge load on the database as it has to calculate the number of fields and their sizes for each row on the table.select field1,field2,field3 from table would be more efficent as this calcualtion would only be done once.

3)Confused Browser. the browser is expecting a <td> but doesnt know the size or type of the data as it wont exist until the php has finished. Look closely at your form it has the following <div><form>...</div>...</form></div>

4)Syntax error. a syntax error in your php will almost certainly cause havoc with your layout. use your broswer's view source function to check.

5)use <div> with css instead of <table> for layout. loads of discussions as to why, but for now it will help you track any errors in your php.

hope this helps