0

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>

Edited by qariella: n/a

5
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by syamsasi
0

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

Edited by pritaeas: n/a

0

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
0

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.

0

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

0

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

0

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,

0

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( $, ; , . ,")

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.