Not Inserting Record

Codes here !

Moderators: egami, macek, gesf

Post Reply
jagjittcl
New php-forum User
New php-forum User
Posts: 9
Joined: Wed Jul 03, 2013 10:14 pm

Wed Jul 10, 2013 8:55 am

Hi

Below code is not inserting record . In the table i have 1 field ID which is auto-generated.

<?php
include 'db.php';
$firstname=$_POST['firstname'];
$middlename=$_POST['middlename'];

$query = "INSERT INTO emp_master ".
"(firstname,middlename) ".
"VALUES ".
"('$firstname,$middlename')";
if( $mysqli->query($query) )
{
echo "Record Created.";
}else{
echo "Unable to create New record.";
}
?>

Thanks

developerahusain
New php-forum User
New php-forum User
Posts: 44
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow

Wed Jul 10, 2013 9:23 am

This is the query i'm using for inserting records.

if(mysql_query("insert into job_titles(super_category,category,sub_category) values ('"
.$_POST['super_cats']."','".$category."','".$sub_category."')") or die("the eror ".mysql_error())) ;

Modify the query as per your requirements.

Developerahusain

jagjittcl
New php-forum User
New php-forum User
Posts: 9
Joined: Wed Jul 03, 2013 10:14 pm

Wed Jul 10, 2013 9:38 pm

Hi developerahusain

Thanks.

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Thu Jul 11, 2013 6:40 am

You need to write error validation for each of the code that you write, especially when dealing with database calls. Otherwise, you will never know why your code is not working.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests