MySQL Forums
Forum List  »  PHP

index/redirect problem on localhost/mysql
Posted by: Charles Siegel
Date: January 16, 2019 04:42AM

Hi.. I am just learning mysql and php. I thought I had mysqli and pdo issues fixed but did something stupid I suppose. Trying to learn php connecting with mysql, I used this code:

<?php
$servername = "localhost";
$username = "zzzz";
$password = "zzzz";
$dbname = "zzzzz";

// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);

if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM golfers WHERE lname = 'Adams'";

if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error deleting record: " . $conn->error;
}

$conn->close();

copied and pasted in haste and didn't notice this line which I don't understand: header("Location: index.php");

Immediately after doing this the localhost/php_del.php url did not work at all. After rebooting the computer I found that none of my scripts that connect php to mysql work at all. I get this message now: Fatal error: Uncaught Error: Class 'mysqli' not found in C:\Apache24\htdocs\php_del.php:8 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\php_del.php on line 8. I believe I have screwed up some index or caused a redirection problem.

I have no idea how to fix this. Can anyone help?

Thanks much!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.