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

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -