好的,所以我真的不懂PHP,当有人提交表单时,需要检查该datetimestamp是否已经在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';
};
?>
它过去常常起作用,但现在它总是说它实际上并不在表中。
答案 0 :(得分:0)
在localhost.php
的末尾写下以下行mysql_select_db($database_localhost);
答案 1 :(得分:0)
试试这段代码:
Localhost.php
<?php
$hostname_localhost = "localhost";
$database_localhost = "bookings";
$username_localhost = "username";
$password_localhost = "password";
$tablename_localhost = //your name of your table from database
$localhost = mysql_pconnect($hostname_localhost, $username_localhost, $password_localhost, $tablename_localhost) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Main.php
<?php require_once('../Connections/localhost.php');
$date = $_POST['date'];
$result = mysql_query($localhost, "SELECT * FROM bookingtable WHERE Date of Session = '$date'");
if(mysql_num_rows($result) > 0) {
echo 'the date was found';
} else {
echo 'the date wasnt found';
};
?>