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

Warning: mysqli_error() expects exactly 1 parameter, 0 given

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Warning: mysqli_error() expects exactly 1 parameter, 0 given

Postby Sunny » Mon Oct 28, 2013 11:53 pm

Hi

Below code gives me this message "Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\Projects\process.php on line 20" . It is not saving record

<?php
require'db_con.php';

$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');";
$retval = mysqli_query( $conn ,$sql);
mysqli_close($conn);
?>

Database Connection File is
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'test';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass,$db);
if(! $conn )
{
die('Could not connect: ' . mysqli_error());
}
?>


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

Re: Warning: mysqli_error() expects exactly 1 parameter, 0 g

Postby tiger » Tue Oct 29, 2013 10:08 pm

Sunny,

1- I see that your database name is 'test', and you did not put that in your $sql variable.
2- you're missing a ' ' around the $phone variable.

So, try this code and see if it fixes the problem.

Code: Select all
$sql="INSERT INTO `test`.`registeration` (`fname`, `email`, `password`, `phone', `dob`, `gender') VALUES ('$fname','$email','$password',`$phone`,'$dob','$gender');";
tiger
New php-forum User
New php-forum User
 
Posts: 16
Joined: Thu Jun 23, 2011 9:28 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

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