Maximilian Maximilian - 10 months ago 70
PHP Question

How to debug mysqli_query?

I have a connection to my database:

// 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

$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:

echo "Success:";

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
is not successful?

How can I debug it?

Answer Source

You are looking for mysqli_error() function.

Problem here is that date is a reserved word, so you have to escape that: `date`

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download