-1

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\programs\School\reg.php on line 4

This is the error generated and find my coding below. Will be helpful if I am answered immediately.

<?php
  if(isset($_POST['Register'])) {
      $con=mysql_connect('localhost', 'root', '');
      $insert="insert into member(`Name`, `contact_email`, `contact_number`, `Year_joined`, `Degree`, `password`)values($_POST['Name'], $_POST['contact_email'], $_POST['contact_number'], $_POST['Year_joined'], $_POST['Degree'], $_POST['password'])";
      if($select_db=mysql_select_db('ulagappar', $con)) {
         $query=mysql_query($insert);
         echo "<script type='text/javascript'>alert('Registered successfully!!!')</script>";
      }
  }
?>
<form action="reg.php" method="Post">
  Name : <input type="text" name="Name"><br><br>
  Email: <input type="text" name="contact_email"><br><br>
  phone: <input type="Number" name="contact_number"><br><br>
  Batch: <input type="Number" name="Year_joined"><br><br>
  Qualification: <input type="text" name="Degree"><br><br>
  Password : <input type="password" name="password"><br><br>
  <input type="Submit" name="Register">
</form>

1 Answers1

0

Replace your query with this

$insert="insert into member(`Name`, `contact_email`, `contact_number`, `Year_joined`, `Degree`, `password`)values('{$_POST['Name']}', '{$_POST['contact_email']}', '{$_POST['contact_number']}', '{$_POST['Year_joined']}', '{$_POST['Degree']}', '{$_POST['password']}')";

You are inserting wrong data matched with your database datatype. Error is because of that.

Tejas Mehta
  • 791
  • 1
  • 6
  • 15