Image Allignment?

Soldato
Joined
11 Apr 2003
Posts
4,208
Location
Notts
Hi all, just working on my site content, and my images leave large gaps to the side of them, I can resolve this by using allign="left" however my site does not validate, is there anyway to get this feature working and make the site valid?

Thanks :)

http://cpanel.lincoln.ac.uk/dci125/reviews/software/jk2.shtml

*EDIT* Also found my insert page does not validate, when it has my php in, for some reason, it seems to think I have not closed my div tags, even though I have, any ideas?

http://cpanel.lincoln.ac.uk/dci125/guestbook/insert.php

http://validator.w3.org/check?uri=h...charset=(detect+automatically)&doctype=Inline
 
Last edited:
The insert page goes to:

"Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!"

The source is
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-3" >
	<meta name="description" content="This website relates to computer hardware, software, modding, overclocking and more" >
	<meta name="keywords" content="Jcb33,Computer,Computers,Overclocking,Overclock,Overclocked,Hardware,Software,Graphics,CPU,Monitor,Motherboard,Memory" >
	<meta name="Author" content="Jason Gunn" >
	<META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://cpanel.lincoln.ac.uk/dci125/guestbook/guestbook.shtml">
	<link rel="shortcut icon" href="../favicon.ico">
	<title>Welcome To Overclockersvortex.co.uk, Technology, Tips And More</title>

	<link rel="stylesheet" href="../assets/css/Style.css" type="text/css">
</head>
<body>
	<div id="wrap">  
		<div id="headwrap">	
			<div id="textsite">
				<a href="../text/index.html">Text Only Site</a>
			</div>
			<div id="logo">				
				<img src="../assets/images/global/logo.jpg" alt="Banner, containing images of hardware, and the text Overclockersvortex.co.uk" name="Site_Banner" width="70%" height="100%" />
			</div>

			<div id="navbar">
				<!--#include virtual="../assets/library/global/nav_bar.html" -->
			</div>	
		</div>
  		<div id="mainwrap">
    			<div id="sidenavbar"><!--#include virtual="../assets/library/global/left_nav_bar.html" --></div>
		<div id="content">
			Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!

Which definitely has some unclosed divs :)
 
|Ric| said:
The insert page goes to:

"Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!"


Which definitely has some unclosed divs :)

See the full code is:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-3" >
	<meta name="description" content="This website relates to computer hardware, software, modding, overclocking and more" >
	<meta name="keywords" content="Jcb33,Computer,Computers,Overclocking,Overclock,Overclocked,Hardware,Software,Graphics,CPU,Monitor,Motherboard,Memory" >
	<meta name="Author" content="Jason Gunn" >
	<META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://cpanel.lincoln.ac.uk/dci125/guestbook/guestbook.shtml">
	<link rel="shortcut icon" href="../favicon.ico">
	<title>Welcome To Overclockersvortex.co.uk, Technology, Tips And More</title>
	<link rel="stylesheet" href="../assets/css/Style.css" type="text/css">
</head>
<body>
	<div id="wrap">  
		<div id="headwrap">	
			<div id="textsite">
				<a href="../text/index.html">Text Only Site</a>
			</div>
			<div id="logo">				
				<img src="../assets/images/global/logo.jpg" alt="Banner, containing images of hardware, and the text Overclockersvortex.co.uk" name="Site_Banner" width="70%" height="100%" />
			</div>
			<div id="navbar">
				<!--#include virtual="../assets/library/global/nav_bar.html" -->
			</div>	
		</div>
  		<div id="mainwrap">
    			<div id="sidenavbar"><!--#include virtual="../assets/library/global/left_nav_bar.html" --></div>
		<div id="content">
			<?php
				$sel = mysql_connect("localhost","cpanelu_dci125","MonkeyTeaPot");
				if (!$sel)
				{
 					die('Could not connect: ' . mysql_error());
 				}

				mysql_select_db("cpanelu_dci125", $sel);
				
				if ($_POST['name'] == NULL)
				{
					die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
				}
				elseif ($_POST['email'] == NULL) {
					die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
				}
				elseif ($_POST['comment'] == NULL) {
					die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
				}

				$_POST[name] = strip_tags($_POST[name]);
				$_POST[email] = strip_tags($_POST[email]);
				$_POST[comment] = strip_tags($_POST[comment]);

				$dat="INSERT INTO guestbook (name, email, comment)		
				
							
				VALUES ('$_POST[name]','$_POST[email]','$_POST[comment]')";

				if ($_POST['name'] == NULL)
				{
					die('Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!');
				}
				elseif ($_POST['email'] == NULL) {
					die('Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!');
				}
				elseif ($_POST['comment'] == NULL) {
					die('Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!');
				}
				
				if (!mysql_query($dat,$sel))
  				{
  					die('Error: ' . mysql_error());
  				}
				
				echo "Thank you for leaving a comment! You will return to the guestbook shortly";

				mysql_close($sel)
			?>
				<p>If you are not redirected automaticaly you can return the the guestbook <a href="http://cpanel.lincoln.ac.uk/dci125/guestbook/guestbook.shtml">here </a></p>
			</div>
  		</div>
		<div id="footwrap">
			<div id="footnavbar">
				<!--#include virtual="../assets/library/global/nav_bar.html" -->
			</div>
  			<div id="footer">Copyright Jason Gunn 2007</div>
		</div>
	</div>
</body>
</html>

Any idea how I can fix this problem, and keep my validation in?

With the image I want it to go:

:) test test test test
:) test test test test

Not:
:)
:)
test test test test test test test test
 
|Ric| said:
Yes but you then die(), that stops the php script so it doesn't output anything beyond that point
Hmm, well I want it to echo the error message, then end the php script, which atm it is doing, I dont want it to echo the message then input it anyway
 
A fix might be to have a valid variable that starts true but you set to false when an error is found and then only continues the next checks if it is still valid, then it will just pass all the other checks and close all your divs finally.
Then instead of dying just echo the error.
 
As for the image fix, you want to apply "float: left" to its style (and probably a margin or padding on the right hand side).
 
Would this work?
Code:
			<?php
				$validate = true;
				$sel = mysql_connect("localhost","cpanelu_dci125","MonkeyTeaPot");
				if (!$sel)
				{
 					die('Could not connect: ' . mysql_error());
 				}

				mysql_select_db("cpanelu_dci125", $sel);
				
				if ($_POST['name'] == NULL)
				{
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!");
					$validate = false;
				}
				elseif ($_POST['email'] == NULL) {
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!");
					$validate = false;
				}
				elseif ($_POST['comment'] == NULL) {
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!");
					$validate = false;
				}
				if($validate = true) {
					$_POST[name] = strip_tags($_POST[name]);
					$_POST[email] = strip_tags($_POST[email]);
					$_POST[comment] = strip_tags($_POST[comment]);

					$dat="INSERT INTO guestbook (name, email, comment)		
				
							
					VALUES ('$_POST[name]','$_POST[email]','$_POST[comment]')";

					if ($_POST['name'] == NULL)
					{
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
					}
					elseif ($_POST['email'] == NULL) {
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
					}
					elseif ($_POST['comment'] == NULL) {
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
					}
				
					if (!mysql_query($dat,$sel))
  					{
  						die('Error: ' . mysql_error());
  					}
				}
				
				echo "Thank you for leaving a comment! You will return to the guestbook shortly";

				mysql_close($sel)
			?>
 
Think it should be fine, try it?
You will still get a validation error if you can't connect to the database but then I guess you have more serious problems :p
 
Sadly no, it now allows blank posts

*EDIT* Thanks, with a bit of tweeking I got this working, incase it helps anyone else, here is my code:

Code:
<?php
				$validate = true;
				$sel = mysql_connect("localhost","cpanelu_dci125","MonkeyTeaPot");
				if (!$sel)
				{
 					die('Could not connect: ' . mysql_error());
 				}

				mysql_select_db("cpanelu_dci125", $sel);
				
				if ($_POST['name'] == NULL)
				{
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!";
					$validate = false;
				}
				elseif ($_POST['email'] == NULL) {
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!";
					$validate = false;
				}
				elseif ($_POST['comment'] == NULL) {
					echo "Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!";
					$validate = false;
				}
				elseif($validate = true) {
					$_POST[name] = strip_tags($_POST[name]);
					$_POST[email] = strip_tags($_POST[email]);
					$_POST[comment] = strip_tags($_POST[comment]);

					if ($_POST['name'] == NULL)
					{
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
						$validate = false;
					}
					elseif ($_POST['email'] == NULL) {
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
						$validate = false;
					}
					elseif ($_POST['comment'] == NULL) {
						echo "Im Sorry, One Or More Fields Are Empty As It Apears You Have Used Some Form Of Code, Which Is Not Accepted On This Site (HTML, Javascript, etc) Please Try Again, You Will Now Return To The Guestbook!";
						$validate = false;
					}
					
					elseif($validate = true) {

						$dat="INSERT INTO guestbook (name, email, comment)		
				
							
						VALUES ('$_POST[name]','$_POST[email]','$_POST[comment]')";

						if (!mysql_query($dat,$sel))
  						{
  							die('Error: ' . mysql_error());
  						}
				
				
						echo "Thank you for leaving a comment! You will return to the guestbook shortly";
					}
				}

				mysql_close($sel)
			?>

This stops any nasty code being injected into the guestbook, as well as stopping any blank posts :)

Now to get my image working!
 
Last edited:
Thanks, got it working using divs to wrap it up in, was putting float-left for some reason instead of float: left hence why I could not get it to work :rolleyes:

Just wondering however, is there a way to use the same div twice on one page?

E.G I have 2 left aligned images on my page, and I just want the div around them, so that everything does not left align, however using it twice, as I have here:

http://cpanel.lincoln.ac.uk/dci125/reviews/software/jk2.shtml

Makes the page invalid
 
Yes but you use <div class=""> instead of <div id="">
id should be used when there is one occurrence where as class should be used when there are repeated uses.

You will have to change your css, instead of # to identify the element you use .
 
|Ric| said:
Yes but you use <div class=""> instead of <div id="">
id should be used when there is one occurrence where as class should be used when there are repeated uses.

You will have to change your css, instead of # to identify the element you use .
Thanks, thats all sorted now :) Thank you for all the help!!
 
Back
Top Bottom