html - data to be inserted in database through php page -


<?php @$code = $_post['code']; @$name = $_post['name'];  @$city = $_post['city'];  $connect = mysql_connect("localhost", "root", "", "parth") or die("connection failed");  $sql_query = "insert customer_master(customer_code,customer_name,customer_city) values(" . $code . ",'" . $name . "','" . $city . "');"; $result = mysql_query($sql, $connect);  if ($result) {     echo "database connected"; } else {      echo "data not inserted"; } mysql_close($connect); ?> 

the above mentioned code code of inserting data in database data in not been inserted in been displayed ,no errors been displayed please can me solve problem.

you have made mistake on here ".$code.", missed single quote , using mysql depreciated use mysqli below :

<?php          @$code=$_post['code'];         @$name=$_post['name'];          @$city=$_post['city'];          $connect=mysqli_connect("localhost","root","","parth")  or die("connection failed");              $sql_query="insert customer_master(customer_code,customer_name,customer_city) values('".$code."','".$name."','".$city."');";             $result=mysqli_query($sql,$connect);  if($result)     { echo "database connected";      }             else         {  echo "data not inserted";         }         mysqli_close($connect);           ?>  

Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -