在PHP中连接到服务器失败

时间:2022-01-07 01:43:26

The following is my php code

以下是我的PHP代码

<?
$server = 'mysql.hostinger.in';
$user = '*********';
$pass = '****';
$db = '********';
$email = $_POST['email'];
echo $email;
$conn = mysqli_connect($server,$user,$pass,$db);
$in = "INSERT INTO Emails (Email)
VALUES ($email)";


if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";

} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
?>

whenever I compile the code it gives me an error.

每当我编译代码时,它都会给我一个错误。

1 个解决方案

#1


0  

<?php 
if(isset($_POST['your_submit_button_name'])){
$server = 'mysql.hostinger.in';
$user = '*********';
$pass = '****';
$db = '********';
$email = htmlspecialchars($_POST['email']);
echo $email;
$conn = mysqli_connect($server,$user,$pass,$db);
$in = "INSERT INTO `Emails` (Email) VALUES ('$email')";
if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
?>

#1


0  

<?php 
if(isset($_POST['your_submit_button_name'])){
$server = 'mysql.hostinger.in';
$user = '*********';
$pass = '****';
$db = '********';
$email = htmlspecialchars($_POST['email']);
echo $email;
$conn = mysqli_connect($server,$user,$pass,$db);
$in = "INSERT INTO `Emails` (Email) VALUES ('$email')";
if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
?>