-1

Alright so I am currently trying to make a system to take applications and it was working until I added the rest of the questions :

<?php
include_once('db.php');

$user =$_POST['username'];
$job =$_POST['job'];
$active =$_POST['active'];
$why =$_POST['Q1']
$le =$_POST['Q2']
$skype =$_POST['skype']

if(mysqli_query($conn, "INSERT INTO app (username,job,active,why,le,skype) VALUES ('$user','$job','$active','$why','$le','$skype')"))
echo"successfully inserted";
else
echo "failed";
?>

But when I have it like that I get this error

Parse error: syntax error, unexpected '$le' (T_VARIABLE) in C:\xampp\htdocs\app_insert.php on line 8

Keep in mind I am using xampp with Apache and Mysql, anyone know whats happening?

  • `PHP` needs semi-colon at the end of each instruction line, Which is called [Instruction separation](http://php.net/manual/en/language.basic-syntax.instruction-separation.php) – Peyman Mohamadpour Feb 28 '16 at 05:38

2 Answers2

-1

You missed out the semi-colon, ; for:

$why =$_POST['Q1']
$le =$_POST['Q2']
$skype =$_POST['skype']

It should be:

$why =$_POST['Q1'];
$le =$_POST['Q2'];
$skype =$_POST['skype'];
Panda
  • 6,955
  • 6
  • 40
  • 55
-1

You are missing the semi-colon and the insert SQL statement seems incorrect. You are passing the string to SQL statements instead of the value

<?php
include_once('db.php');

$user =$_POST['username'];
$job =$_POST['job'];
$active =$_POST['active'];
$why =$_POST['Q1'];
$le =$_POST['Q2'];
$skype =$_POST['skype']

if(mysqli_query($conn, "INSERT INTO app (username,job,active,why,le,skype) VALUES ('{$user}','{$job}','{$active}','{$why}','{$le}','{$skype}')"))
echo"successfully inserted";
else
echo "failed";
?>
Greg
  • 44
  • 5