I am new in php and sql. I was trying to make a chat web,but i had too many errors in php, it is connected to database but im not able to Insert things in my database. I have two errors at the time that are hard to understand for me,
1
FATAL ERROR:Call to a member function mysqli_num_rows() on a non-object in E:\xamp\htdocs\chatting\post.php on line 20
2
NOTICE:undifined index: in E:\xamp\htdocs\chatting\post.php on line 13
the php script that is giving these errors is
<?php
$connect= new mysqli('localhost', 'root','' ,'user');
if($connect->connect_error){
die('connection failed bruh');
} else
echo 'connected';
$message= $_POST[`message`];
$name= $_POST[`name`];
$sql = 'INSERT INTO user (name, message) VALUES (`{$name}`, `{$message}`)';
$result = $connect-> query($sql);
if ($result->mysqli_num_rows($sql) > 0){
while ($row=$result->fetch_assoc()){
echo $row[`$message`];
}
} else
echo '<br> problem';
?>
my sql database's table name is user and it have three colmns
1.id (which is set to auto increment)
2.name
3.message
if anyone can help me get rid of these will be very thankful and if there are more errors in my php code then please tell me