Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Not Inserting Record

Codes here !

Moderators: macek, egami, gesf

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
jagjittcl
New php-forum User
New php-forum User
 
Posts: 9
Joined: Wed Jul 03, 2013 10:14 pm

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
developerahusain
New php-forum User
New php-forum User
 
Posts: 36
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow

Re: Not Inserting Record

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

Hi developerahusain

Thanks.
jagjittcl
New php-forum User
New php-forum User
 
Posts: 9
Joined: Wed Jul 03, 2013 10:14 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.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: CharlyAnderson and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.