clear all the entries from a table with php

mysql, php

Solution

This is a typo. You used `mysql_query()` instead of `mysqli_query()`. Change

mysql_query($sql);

to:

mysqli_query($con, $sql);

Also note that the param lists of both functions differ. `mysqli_expects()` a connection handle as it's first param.

Problem

I want to clear all the entries from one table in MySQL with php I tried this: ``` <?php // Create connection $con=mysqli_connect("localhost","username","password","dbName"); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "TRUNCATE TABLE tableName"; mysqli_query($sql); ?> ``` but it didn't work. why?

Original source