# PHP/MySQL Insert Statement not working

**URL:** <https://forum.kirupa.com/t/php-mysql-insert-statement-not-working/258580>\
**Category:** programming\
**Created:** [April 25, 2008, 12:58pm UTC](https://forum.kirupa.com/t/php-mysql-insert-statement-not-working/258580 "2008-04-25T12:58:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DangerousDan](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@DangerousDan](https://forum.kirupa.com/u/DangerousDan)\
**Post date:** [April 25, 2008, 12:58pm UTC](https://forum.kirupa.com/t/php-mysql-insert-statement-not-working/258580/1 "2008-04-25T12:58:38Z")

</div>

I’m able to read the data from my database but I’m unable to insert data into it.

```php
<?php
 //Submits responses into the database
 include("db.php");
 header( 'Location: /results.php' ) ;
 
 $inform = $_POST['inform'];
 $email = $_POST['email'];
 $member = $_POST['member'];
 $attending = $_POST['attend'];
 $tour = $_POST['tour'];
 $liketour = $_POST['liketour'];
 $find = $_POST['find'];
 $compare = $_POST['compare'];
 $slength = $_POST['time'];
 $vendors = $_POST['vendors'];
 $experience = $_POST['experience'];
 $stuservice = $_POST['students'];
 $food = $_POST['food'];
 $signs = $_POST['signs'];
 $organization = $_POST['organization'];
 $clean = $_POST['clean'];
 $dj = $_POST['dj'];
 $comem = $_POST['comm'];
 $comments = $_POST['comments'];
 $contact = $_POST['contacts'];
 $phone = $_POST['phone'];
 $query = "INSERT INTO survey
VALUES ('$inform', '$email', '$member', '$attending', '$tour', '$liketour', '$find', '$compare', '$slength', '$vendors', '$experience', 
'$stuservice', '$food', '$signs', '$organization', '$clean', '$dj', '$comem', '$comments', '$contact', '$phone')";
 mysql_query($query) or die(myql_error());
 
?>

```

There’s actually a field before the inform, the auto increment ID field.  
Here’s the top of the form which I assume is correct, its been a while since I’ve done this.

```auto
<form action="survey.php" method="post">

```

Anyway, I’m not getting any errors what-so-ever. I’m also not getting any data what-so-ever.

I’m thinking that the header function might be running before the rest of the code? The header function doesn’t seem to work if I place it below the rest of the code, suggestions anyone?
