Question on my practical


Database connection code

	/*Connect Database*/
	$conn = mysqli_connect('localhost','root','') or die(mysqli_error());
	/*Select Database*/
	$select_db = mysqli_select_db($conn,'practise') or die(mysqli_error());

//Database connection

//Insert data into database

//Sql Query to Insert Data in table
$sql="INSERT INTO pract SET name='$name',
	/*Execute Query*/
	$result=mysqli_query($conn,$sql) or die (mysqli_error());
		echo "Error";

Error message received

Warning: mysqli_error() expects exactly 1 parameter,

Please kindly help to fixed the error


You know, if you took two seconds to RTFM you would know what the problem is. I will make it easy for you. Click this link and read the page.

We don’t mind helping, but for gawd sake, try putting in a little effort on your own. This page will be helpful if you are going to be posting on forums.

Aside from your actual problem, never ever put variables in your query. You need to use PDO with Prepared Statements.

Do not output internal system errors to the user. That info is only good to hackers.

Always kill the script after a header redirect or the script will keep running to the end.

Do not create variables for nothing. You already have the POST variables, just use them.

The INSERT INTO SET syntax is not an SQL standard.

Standard syntax:

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...); 

Welcome to the forum. :grinning: