Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Record not Added

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Record not Added

Postby Sunny » Tue Oct 29, 2013 10:13 pm

Hi

Below code always gives this message "Input Data is Fail" . Secondly i have not written phone as '$phone' in Insert statement because Phone Data Type is tinyint.

<?php

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'test';
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db);

$fname = trim($_POST['fname']); // trim remove white space
$email = trim($_POST['email']);
$password = trim($_POST['password']);
$phone = trim($_POST['phone']);
$birth = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
$gender = $_POST['gender'];

$sql="INSERT INTO `registeration` (`fname`, `email`, `password`, `phone', `dob`, `gender') VALUES ('$fname','$email','$password',$phone,'$dob','$gender');";
if($conn->query($sql) === false)
{
echo("<br>Input data is fail");
}
else
{
echo("<br>Input data is succeed");
}

mysqli_close($conn);
?>
Sunny
New php-forum User
New php-forum User
 
Posts: 23
Joined: Wed Nov 30, 2011 6:51 am

Re: Record not Added

Postby RYMK0087 » Wed Oct 30, 2013 12:08 am

Hi,

Try this:

Code: Select all
$sql="INSERT INTO `registeration` (`fname`, `email`, `password`, `phone', `dob`, `gender') VALUES ('".$fname."','".$email."','".$password."',".$phone.",'".$dob."','".$gender."');";


PHP variables should be outside the quoted INSERT statement. Also check the closing quotes for 'phone' and 'gender' for consistency.
RYMK0087
New php-forum User
New php-forum User
 
Posts: 5
Joined: Tue Oct 08, 2013 5:38 am

Re: Record not Added

Postby Sunny » Wed Oct 30, 2013 1:10 am

Hi

Still not adding record

Thanks
Sunny
New php-forum User
New php-forum User
 
Posts: 23
Joined: Wed Nov 30, 2011 6:51 am

Re: Record not Added

Postby Sunny » Wed Oct 30, 2013 1:31 am

resolved
Sunny
New php-forum User
New php-forum User
 
Posts: 23
Joined: Wed Nov 30, 2011 6:51 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests

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