Member Avatar for Puster

Hello!
I've made a site called 'About us' on norwegian it means 'omoss' in my code;)
But when i am displaying my code the hole page is white!
I can't find the error.
Can someone pleas help me?

<?php include('connect.php'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>rediger omm oss</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({
	
	theme : "advanced",
	mode : "textareas",
	plugins : "fullpage",
	theme_advanced_buttons3_add : "fullpage"
});
</script>
</head>

<body>

<div class="rediger"><?php	if ($_POST['Oppdater'])
		{
			$nytt = ($_POST['omoss']);
		
			$oppdater = mysql_query("SELECT * FROM 'omoss' WHERE 'id'='1'") or die(Error);
			$row = mysql_fetch_assoc($oppdater);
			
			$gammelt = $row['innhold'];
			
			$querychange = mysql_query("
						UPDATE omoss SET innhold='$nytt' WHERE id='1'
						");
			echo "
					
            <form action='rediger_om.php' method='post'>
            <textarea name='omoss' id='omoss'>$gammelt</textarea>
            <input type='submit' value='Oppdater' id='oppdater' name='oppdater' />
</form>
";
		}
?>
</div>
</div>
</body>
</html>

Thanks for the help!:)

Recommended Answers

All 4 Replies

The only thing that jumps out is that the if statement is false, try taking that out and see if anything displays?

Member Avatar for Puster

what do you mean?

<?php include('connect.php'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>rediger omm oss</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({
	
	theme : "advanced",
	mode : "textareas",
	plugins : "fullpage",
	theme_advanced_buttons3_add : "fullpage"
});
</script>
</head>

<body>

<div class="rediger"><?php	if ($_POST['Oppdater'])//Try taking this line out and its corresponding "}" to test the code without a condition?
		{
			$nytt = ($_POST['omoss']);
		
			$oppdater = mysql_query("SELECT * FROM 'omoss' WHERE 'id'='1'") or die(Error);
			$row = mysql_fetch_assoc($oppdater);
			
			$gammelt = $row['innhold'];
			
			$querychange = mysql_query("
						UPDATE omoss SET innhold='$nytt' WHERE id='1'
						");
			echo "
					
            <form action='rediger_om.php' method='post'>
            <textarea name='omoss' id='omoss'>$gammelt</textarea>
            <input type='submit' value='Oppdater' id='oppdater' name='oppdater' />
</form>
";
		}
?>
</div>
</div>
</body>
</html>

Where '$_POST' var comes from? '$_POST' are always comes from via HTML form. Are you trying to show this page after submitting the form from the other pages.
Your codes are not wrong, but the logic is wrong. Print some value if the '$_POST' var has not defined.

<?php if ($_POST)
{
$nytt = ($_POST);

$oppdater = mysql_query("SELECT * FROM 'omoss' WHERE 'id'='1'") or die(Error);
$row = mysql_fetch_assoc($oppdater);

$gammelt = $row;

$querychange = mysql_query("
UPDATE omoss SET innhold='$nytt' WHERE id='1'
");
echo "

<form action='rediger_om.php' method='post'>
<textarea name='omoss' id='omoss'>$gammelt</textarea>
<input type='submit' value='Oppdater' id='oppdater' name='oppdater' />
</form>
";
}
?>

<?php	
	if (isset($_POST['Oppdater'])){
		$nytt = ($_POST['omoss']);
	
		$oppdater = mysql_query("SELECT * FROM 'omoss' WHERE 'id'='1'") or die(Error);
		$row = mysql_fetch_assoc($oppdater);
		
		$gammelt = $row['innhold'];
		
		$querychange = mysql_query("
					UPDATE omoss SET innhold='$nytt' WHERE id='1'
					");
?>			
		<form action='rediger_om.php' method='post'>
		<textarea name='omoss' id='omoss'>$gammelt</textarea>
		<input type='submit' value='Oppdater' id='oppdater' name='oppdater' />
		</form>
<?php
		}
	else{
?>
This text will show when the 'if' statement ignore.
<?php
	}
?>

Try with above codes. And you should use 'isset()' method for checking had the var already set.
By seeing you code, you may be trying to get the '$_POST' via submitting the form from the other pages. If it like so, you can use ($_POST != ''). If the '$_POST' is not null, the script run otherwise do other process as 'else' statement.

commented: good avatar) good answer) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.