samedi 28 avril 2018

Php insert into mysql doenst work [duplicate]

This question already has an answer here:

I have create a mysql database in mysql free hosting. Then i created a php code using notepad++. I'm trying to insert into mysql database. the problem is that it looks like doesnt running my code. It just shows all the code which i wrote in my browser.

<?php
$servername = "sql2.freemysqlhosting.net";
$username = "sql2234926";
$password = "mypassword";
$dbname = "sql2234926";

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

$sql = "INSERT INTO customermaster(code, name, email)
VALUES ('1234', 'Doe', 'john@example.com')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Image




Aucun commentaire:

Enregistrer un commentaire