I have a connection to my database:
$con=mysqli_connect("localhost","xxxx","xxxxx","xxxxxx");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
which returns no error.
I then try to perform a mysqli_query
:
$result = mysqli_query($con,"INSERT INTO entries (name, genre, info , date , website , twebsite, video , tvideo, image, extra_genre)
VALUES ('".$name."', '".$type."', '".$info."', '".$date."', '".$url."', '".$href."', '".$_POST["video"]."', '".$videotype."', 'video images/".$photo."', '".$type2."')");
with the alert whether this insertion to the database has worked or not:
if($result)
{
echo "Success:";
}
else
{
echo "error inserting data into database: ";
}
When I perform my code I get the output error inserting data into database:
But I have no ides why $result
is not successful?
You are looking for mysqli_error()
function.
Problem here is that date
is a reserved word, so you have to escape that: `date`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With