每当我编译代码时,都会出现错误。 最佳答案 " . mysqli_error($conn); } } ?> 关于php-6ren">
gpt4 book ai didi

php - PHP 连接服务器失败

转载 作者:行者123 更新时间:2023-11-29 21:38:12 25 4
gpt4 key购买 nike

以下是我的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);
}
?>

每当我编译代码时,都会出现错误。

最佳答案

<?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);
}
}
?>

关于php - PHP 连接服务器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34747298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com