<?php
$servername = "localhost";
$username = "root";
$password = "Rachel";
$db = "hairdressingapointments";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected Sussessfully";
mysql_select_db('Hairdressingapointments', $conn) or die(mysql_error());
$sql = "SELECT `ApointmentDate`, `ApointmentTime` FROM `apointments` WHERE `staff_id`=1 && `quantity`>0";
if(!mysql_query($sql)){
die('Error: ' . mysql_error());
}
echo $sql;
mysql_close();
?>
花了好几个小时试图解决这个问题并且我猜测它的东西如此简单。找回以下错误: 警告:mysql_select_db()期望参数2是资源,第15行的C:\ wamp2 \ www \ hairdressingapointments \ TeresaApointments.php中给出的对象,
mysql_select_db('Hairdressingapointments', $conn) or die(mysql_error());
答案 0 :(得分:0)
您已使用
连接到数据库mysqli_connect(...);
所以,你不需要
mysql_select_db(....);
同时将查询更改为此
$ sql =“SELECT ApointmentDate,ApointmentTime FROM apointsments WHERE staff_id = 1 AND quantity&gt; 0”;
如果您使用SQLWorkbench或SQLYog或其他工具,您可以输入SQL并确保它在将其添加到脚本之前有效。
另外,请确保表名真的是
apointments
而不是
获得了这些信息约会