I wanted to create a php script to delete a certain row from my mysql database, but it shows
error deleting record:Table 'test.school' doesn't exist.
<?php
$servername="localhost";
$username="root";
$password="";
$dbname="test";
$conn= new mysqli($servername,$username,$password,$dbname);
if($conn->connect_error)
{
die("connection failed:".$conn->connect_error);
}
$sql="DELETE from school where rno='5'";
if($conn->query($sql)===TRUE)
{
echo "Record deleted successfully";
}
else
{
echo "error deleting record:".$conn->error;
}
$conn->close();
?>
Try running the query directly from your SQL client (PhpMyAdmin, Workbench or something similar), if that works, then there is something wrong with your connection.
This has happened to me once before, what I did was I just exported the database/table then deleted it from my client, then re-added the database/table. It usually resolves itself with that (maybe the table wasn't properly saved into the database or something).
Check if the table has been "renamed" by the client, like maybe there was an extra space added to the beginning of the name of the table or something similar.
if($conn->connect_error)
{
die("connection failed:".$conn->connect_error);
}
$sql="DELETE from school where rno='5'";
$query = mysqli_query($conn, $sql);
if($query)
{
echo"Deleted Successfully..";
}
else
{
echo"Failed..";
}
Try this one,maybe this one will work for you.