CodeAndCoins Forum

Official Forum of YouTube/CodeAndCoins Channel

Any problem, other than on a youtube video.
#57
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in C:\wamp64\www\clinic\insert.php on line 8
This is my coding.

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "clinic";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("connection failed: " . $conn->connect_error);
}

$patient_id = $_POST['txt_patientid'];
$patient_name = $_POST['txt_patientname'];
$address = $_POST['txt_address'];
$treatment= $_POST['txt_treatment'];
$email = $_POST['txt_email'];
$telephone_no = $_POST['txt_telephoneno'];

$sql = "INSERT INTO tbl_registration (patient_id, patient_name, address, treatment, email, telephone_no) VALUES('$patient_id', '$patient_name','$address', '$treatment', '$email', '$telephone')";

if ($conn->query($sql) === TRUE) {
$last_id = $conn->insert_id;
echo "New record created successfully. Last inserted ID is: " . $last_id;
} else

{
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
#67
sorry, can I ask one last question? why this error occurs?

Fatal error: Uncaught Error: Call to undefined function mysql_error() in C:\wamp64\www\clinic\afterupdate.php on line 34

echo "Query Failed: " . mysql_error(); <- this is line 34

This may be happen because of mix matching the cod[…]

sorry, can I ask one last question? why this err[…]

Intro

Hi, I'm Jef. I've been living in Thailand for the […]

If browser return php code, that means php code is[…]