Please help me, I dont know how to fix this problem, been sitting with it for days...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">	
<head>
<title>telefonbok</title>

</head>

<body>
<?php//DATABASEN

	mysql_connect('localhost', 'xxxxx', 'xxxxxx') or die (mysql_error());
	mysql_select_db('sanstr09') or die(mysql_error());
		
	if(isset($_POST['save']))
	{
	header("Location: index.php");

	//Informationen från Index.php
	$fnamn = $_POST ['fnamn'];
	$enamn = $_POST ['enamn'];	
	$telefonnummer = $_POST['telefonnummer'];
	$favorit = $_POST ['favorit'];	
	$beskrivning = $_POST['beskrivning'];
	
	//SÄKERHETEN
	$fnamn = mysql_real_escape_string($fnamn);
	$enamn = mysql_real_escape_string($enamn);
	$telefonnummer = mysql_real_escape_string($telefonnummer);
	$favorit = mysql_real_escape_string($favorit);
	$beskrivning = mysql_real_escape_string($beskrivning);
	
	
	//ÄNDRAR $FAVORIT TILL RÄTT VÄRDE INNAN DET SKICKAS TILL DATABASEN
         if($favorit == on)
         {
             $favorit = 1;
         }
         else
             $favorit = 0;
	
	//LÄGGS TILL I DATABASEN
	mysql_query("INSERT INTO contacts (firstname, lastname, description, phonenumber, favorite)
	VALUES ('$fnamn', '$enamn', '$beskrivning', '$telefonnummer', '$favorit')") or die(mysql_error());


	}
	
	else
		echo "Välj tjänst"?>
	</body>
</html>

Recommended Answers

All 7 Replies

<?php//DATABASEN does not work on my system. I have to use <?php //DATABASEN . Note the extra space. Perhaps this causes your issue.

Gewtting another error.. Warning: Cannot modify header information - headers already sent by (output started at /home/sanstr09/www/lab4/phonebook.php:9) in /home/sanstr09/www/lab4/phonebook.php on line 16

if(isset($_POST['save']))
	{
	header("Location: index.php"); <---- This one

You get that, because you have already outputted html before calling this redirect. If you want to change this, you have to output the html heading only when you don't redirect.

Warning: Cannot modify header information - headers already sent by (output started at /home/sanstr09/www/lab4/phonebook.php:9) in /home/sanstr09/www/lab4/phonebook.php on line 16

This warning can be ignored by putting

ob_start("ob_gzhandler");

on the top of the page

Yeah i need huge help it keeps saying Parse error: syntax error, unexpected T_STRING on line 1886, iv tryed everyone of thm codes!!! BUT THE PROBLEM ISNT ON THE WEBPAGE ITS THE WHOLE WEBPAGE like i was it then boom Parse error: syntax error, unexpected T_STRING just comes on now i cant get back on the site, and them codes are pointless
cause there's nowhere to put them, please help

you cant post a code on a webpage that says
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /var/www/hotornot/banner_conf.php on line 1886 everytime you open it.
ITS RELY STARTING TO GET TO ME,

unexpected T_STRING error is due to the typing mistakes in program. Just check for
the required spaces are there
check proper symbols are there( $, ; , . ,")

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.