I’m new to mysql queries and just couldn’t get this mysqli statement to insert into mysql. Is there something wrong with my script setup or my $sql? (I am getting no errors though, its just not inserting)
<?php
$login = "coolkidz"; //this line insets into username
$sname = "heyu";
$city = "beautiful";
$empass = "awesome";
$eusername = "what";
$mcode = "nice";
$sql = "INSERT INTO login(sname, city, empass, eusername, mcode, username) VALUES('$sname', '$city', '$empass', '$eusername', '$mcode', '$login')");
$hostname_Database = "censored";
$database_Database = "censored";
$username_Database = "censored";
$password_Database = "censored";
$mysqli = new mysqli($hostname_Database, $username_Database, $password_Database, $database_Database);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query($sql);
if (!$result) {
printf("%s\n", $mysqli->error);
exit();
}
?>
1 Answer