gpt4 book ai didi

PHP从表中选择数据,不起作用

转载 作者:行者123 更新时间:2023-11-29 22:03:02 24 4
gpt4 key购买 nike

好吧,我不太了解 PHP,当有人提交表单时,它需要检查该日期时间戳是否已经在 mysql 表中,然后执行某些操作。

localhost.php:

<?php 
$hostname_localhost = "localhost";
$database_localhost = "bookings";
$username_localhost = "username";
$password_localhost = "password";
$localhost = mysql_pconnect($hostname_localhost, $username_localhost, $password_localhost) or trigger_error(mysql_error(),E_USER_ERROR);
?>

主文件:

<?php require_once('../Connections/localhost.php'); ?>
<?php
$date = $_POST['date'];

$result = mysql_query("SELECT * FROM `bookingtable` WHERE `Date of Session` = '$date'");
if(mysql_num_rows($result) > 0) {
echo 'the date was found, please try another';
} else {
echo 'the date wasnt found';
};
?>

它曾经有效,但现在它总是说它不在表中,而实际上它在表中。

最佳答案

在 localhost.php 末尾写入以下行

mysql_select_db($database_localhost);

关于PHP从表中选择数据,不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32427581/

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