Can someone explina me this error on 42

I have to make Questionnaire with database so I made it like this but won't load site.

here is code

<?php 
include 'config.php';

$err = array();
					 
if($_POST['doAnketa'] == 'Anketa') 
{ 

foreach($_POST as $key => $value) {
	$data[$key] = filter($value);
}

if(empty($err)) {
$sql_insert = "INSERT into `a4764180_anketa`(`id`,`mesto`,`ime`,`broj_clanova`,`clanova_sa_pravom_glasa`,`adresa`,`broj_zaposlenih`,`broj_nezaposlenih`,`broj_penzionera`,`clan_stranke`,`glavni_problem`,`predlog_resenja`,`sporedni_problemi`,`predlog_resenja2`,`politicar`,`covek_od_poverenja`,`sps`,`ako_ne`) VALUES ('$id','$data[mesto]','$data[ime]','$data[broj_clanova]','$data[clanova_sa_pravom_glasa]','$data[adresa]','$data[broj_zaposlenih]','$data[broj_nezaposlenih]','$data[broj_penzionera]','$data[clan_stranke]','$data[glavni_problem]','$data[predlog_resenja]','$data[sporedni_problemi]','$data[predlog_resenja2]','$data[politicar]','$data[covek_od_poverenja]','$data[sps]','$data[ako_ne]')";
?>

<html>
<head><title>Anketa</title></head>
<body>
<form action="anketa.php" method="post" name="anketa" id="anketa" >

<p>Ime i prezime<input name="ime" type="text" id="ime" size="40"></p>

<p>Broj clanova domacinstva<input name="broj_calnova" type="text" id="broj_clanova" size="20"></p>

<p>Clanova sa pravom glasa<input name="clanova_sa_pravom_glasa" type="text" id="clanova_sa_pravom_glasa" size="20"></p>

<p>Ulica i broj<input name="adresa" type="text" id="adresa" size="40"></p>

<p>Broj zaposlenih u domacinstvu<input name="broj_zaposlenih" type="text" id="broj_zaposlenih" size="40"></p>

<p>Ime i prezime<input name="ime" type="text" id="ime" size="20"></p>

<p>Broj ne zaposlenih<input name="broj_nezaposlenih" type="text" id="broj_nezaposlenih" size="20"></p>

<p>Broj penzionera clanova domacinstva<input name="broj_penzionera" type="text" id="broj_penzionera" size="20"></p>


<input name="doAnketa" type="submit" id="doAnketa" value="Anketa">

</body>
</html>

and I have config in same folder

What's the error ?

What's the error ?

Parse error: syntax error, unexpected $end in /home/a4764180/public_html/anketa/index.php on line 42

I can give you access to ftp, I need this Questionnaire for tomorrow.

You are missing two closing curly brackets (for both your if's).

You are missing two closing curly brackets (for both your if's).

foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
}

and here

if(empty($err)) {
$sql_insert = "INSERT into `anketa`(`id`,`mesto`,`ime`,`broj_clanova`,`clanova_sa_pravom_glasa`,`adresa`,`broj_zaposlenih`,`broj_nezaposlenih`,`broj_penzionera`,`clan_stranke`,`glavni_problem`,`predlog_resenja`,`sporedni_problemi`,`predlog_resenja2`,`politicar`,`covek_od_poverenja`,`sps`,`ako_ne`) VALUES ('$id','$data[mesto]','$data[ime]','$data[broj_clanova]','$data[clanova_sa_pravom_glasa]','$data[adresa]','$data[broj_zaposlenih]','$data[broj_nezaposlenih]','$data[broj_penzionera]','$data[clan_stranke]','$data[glavni_problem]','$data[predlog_resenja]','$data[sporedni_problemi]','$data[predlog_resenja2]','$data[politicar]','$data[covek_od_poverenja]','$data[sps]','$data[ako_ne]')";
}
?>

its ok now... thank you let me try if this goes to database as single article...

Show your code, and use code tags. I don't see a mysql_query()

<?php 
include 'config.php';

$err = array();
					 
if($_POST['doSubmit'] == 'Submit') 
{ 

foreach($_POST as $key => $value) {
	$data[$key] = filter($value);
   }
}


$sql_insert = "INSERT into `a4764180_anketa`(`id`,`mesto`,`ime`,`broj_clanova`,`clanova_sa_pravom_glasa`,`adresa`,`broj_zaposlenih`,`broj_nezaposlenih`,`broj_penzionera`,`clan_stranke`,`glavni_problem`,`predlog_resenja`,`sporedni_problemi`,`predlog_resenja2`,`politicar`,`covek_od_poverenja`,`sps`,`ako_ne`) VALUES ('$id','$data[mesto]','$data[ime]','$data[broj_clanova]','$data[clanova_sa_pravom_glasa]','$data[adresa]','$data[broj_zaposlenih]','$data[broj_nezaposlenih]','$data[broj_penzionera]','$data[clan_stranke]','$data[glavni_problem]','$data[predlog_resenja]','$data[sporedni_problemi]','$data[predlog_resenja2]','$data[politicar]','$data[covek_od_poverenja]','$data[sps]','$data[ako_ne]')";

?>

<html>
<head><title>Anketa</title></head>
<body>
<form action="anketa.php" method="post" name="anketa" id="anketa" >

<p>Ime i prezime<input name="ime" type="text" id="ime" size="40"></p>

<p>Broj clanova domacinstva<input name="broj_calnova" type="text" id="broj_clanova" size="20"></p>

<p>Clanova sa pravom glasa<input name="clanova_sa_pravom_glasa" type="text" id="clanova_sa_pravom_glasa" size="20"></p>

<p>Ulica i broj<input name="adresa" type="text" id="adresa" size="40"></p>

<p>Broj zaposlenih u domacinstvu<input name="broj_zaposlenih" type="text" id="broj_zaposlenih" size="40"></p>

<p>Ime i prezime<input name="ime" type="text" id="ime" size="20"></p>

<p>Broj ne zaposlenih<input name="broj_nezaposlenih" type="text" id="broj_nezaposlenih" size="20"></p>

<p>Broj penzionera clanova domacinstva<input name="broj_penzionera" type="text" id="broj_penzionera" size="20"></p>


<input name="doSubmit" type="submit" id="dosubmit" value="Submit">

</body>
</html>

and sql base is called anketa with one table called anketa

-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 09, 2012 at 02:41 PM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `anketa`
--

-- --------------------------------------------------------

--
-- Table structure for table `anketa`
--

CREATE TABLE IF NOT EXISTS `anketa` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mesto` varchar(200) NOT NULL,
`ime` varchar(200) NOT NULL,
`broj_clanova` varchar(200) NOT NULL,
`clanova_sa_pravom_glasa` varchar(200) NOT NULL,
`adresa` varchar(200) NOT NULL,
`broj_zaposlenih` varchar(200) NOT NULL,
`broj_nezaposlenih` varchar(200) NOT NULL,
`broj_penzionera` varchar(200) NOT NULL,
`clan_stranke` varchar(200) NOT NULL,
`glavni_problem` varchar(500) NOT NULL,
`predlog_resenja` varchar(500) NOT NULL,
`sporedni_problemi` varchar(500) NOT NULL,
`predlog_resenja2` varchar(500) NOT NULL,
`politicar` varchar(200) NOT NULL,
`covek_od_poverenja` varchar(200) NOT NULL,
`sps` varchar(200) NOT NULL,
`ako_ne` varchar(200) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

there is more colums then in php but that php was only to test not finished, when I enter some of fields and press submit I should get one id in mysql in browse of anketa table and see what is inputed name etc...

I solved it

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.