好的,所以我并不真正了解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';
};
?>它曾经起作用,但现在它总是说,它不是在桌子上,当它真的是。
发布于 2015-09-06 20:18:50
在localhost.php的末尾写下一行
mysql_select_db($database_localhost);发布于 2015-09-06 20:39:54
试试下面的代码:
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';
};
?>https://stackoverflow.com/questions/32427581
复制相似问题