Not Inserting Record

Codes here !

Moderators: macek, egami, gesf

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

Not Inserting Record

Postby jagjittcl » 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

Re: Not Inserting Record

Postby developerahusain » 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

Re: Not Inserting Record

Postby jagjittcl » Wed Jul 10, 2013 9:38 pm

Hi developerahusain

Thanks.

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

Re: Not Inserting Record

Postby johnj » 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.


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron