0

Parse error: syntax error, unexpected 'INTO' (T_STRING) in C:\xampp\htdocs\DB\info.php on line 18

<?php 
     $servername = "localhost";  
     $username = "root";  
     $password = "";  
     $conn = mysql_connect ($servername , $username , $password)     or     die("unable to connect to host");  
     $sql = mysql_select_db ('vcet',$conn) or die("unable to connect to database"); 

     //code to insert into db...change the ussername and eamil to the     respective fields in the form....
     $user_info = "INSERT INTO studentinfo (user_name, roll_number,user_batch,user_from,user_year, user_level,F_name,m_name,
                    g_name,mob_number,addressline1, addressline2, city, pmob_number, land_number, cutoff, dept, medium, locality,
                    intrest, scholar, income, user_caste, user_admit, user_stay) 
                    VALUES ('$_POST[user_name]', '$_POST[roll_number]','$_POST[user_batch]','$_POST[user_from]','$_POST[user_year]',
                    '$_POST[user_level]','$_POST[F_name]','$_POST[m_name]','$_POST[g_name]','$_POST[mob_number]','$_POST[addressline1]',
                    '$_POST[addressline2]','$_POST[city]','$_POST[pmob_number]','$_POST[land_number]','$_POST[cutoff]','$_POST[dept]',
                    '$_POST[medium]','$_POST[locality]','$_POST[intrest]','$_POST[scholar]','$_POST[income]',
                    '$_POST[user_caste]','$_POST[user_admit]','$_POST[user_stay]',)"; 
     if (!mysql_query($user_info, $conn))
        {   
            die('Error: ' .     mysql_error()); 
        } 
     echo "Your information was added to the database."; 
     mysql_close($conn); 
 ?> 
Shlomi
  • 4,708
  • 1
  • 23
  • 32
Sasuke Uchiha
  • 421
  • 6
  • 17

2 Answers2

0

first of all you don't have double quotes or single quotes instead you got “ which is not acceptable in php replace them by double qotes " and you will be fine

Ahmad ghoneim
  • 844
  • 7
  • 13
0

It's right query

$user_info = "INSERT INTO studentinfo (user_name, roll_number,     user_batch,user_from,user_year, user_level, F_name, m_name, g_name,     mob_number, addressline1, addressline2, city, pmob_number, land_number, cutoff, dept, medium, locality, intrest, scholar, income, user_caste, user_admit, user_stay) VALUES ('$_POST[user_name]', '$_POST[roll_number]','$_POST[user_batch]','$_POST[user_from]','$_POST[user_year]','$_POST[user_level]','$_POST[F_name]','$_POST[m_name]','$_POST[g_name]','$_POST[mob_number]','$_POST[addressline1]','$_POST[addressline2]','$_POST[city]','$_POST[pmob_number]','$_POST[land_number]','$_POST[cutoff]','$_POST[dept]','$_POST[medium]','$_POST[locality]','$_POST[intrest]','$_POST[scholar]','$_POST[income]','$_POST[user_caste]','$_POST[user_admit]','$_POST[user_stay]')";

Try to use " (double quoted) and remove your last comma in end of query

Engkus Kusnadi
  • 2,386
  • 2
  • 18
  • 40
  • 1
    Parse error: syntax error, unexpected 'information' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\DB\info.php on line 19 – Sasuke Uchiha Jul 15 '16 at 02:44
  • replace this line echo “Your information was added to the database”; with this echo "Your information was added to the database"; – Ahmad ghoneim Jul 15 '16 at 02:54