I run the following code but it's displaying array values not storing data into mysqldb.
<?php
if(! empty( $_POST)){
print_r($_POST);exit;
$mysqli = new mysqli('localhost', 'root','','mydb');
if($mysqli->connect_error){
die('connect error:'. $mysqli->connect_errno .':' . $mysqli->connect_error);
}
}
?>
register.php:
<?php
require('db.php');
$conn=mysqli_connect("localhost","root","");
$name = $_POST['name'];
$name1 = $_POST['skill'];
$name2= $_POST['exp'];
$name3 = $_POST['sele'];
$sql = "INSERT INTO register VALUES('".$name."','".$name1."','".$name2."','".$name3."')";
$insert = $mysqli->query($conn,$sql);
echo $insert;
?>
Getting array result in browser
The connection object is already defined -
$mysqli
. Why$conn
again? Just do -$conn
will be required if you were using theprocedural
approach.mysqli