mysql_query() 期望参数 2 是资源,注意:未定义的变量:DB



这是我得到的错误

警告:main((:依赖系统的时区设置是不安全的。您需要使用date.timezone 设置或 date_default_timezone_set(( 函数。如果您使用了其中任何一种方法,但仍然收到此警告,则很可能拼写错了时区标识符。我们目前选择了时区"UTC",但请设置 date.timezone 以选择您的时区。在/home/dwscodep/public_html/index.php 第 17 行

注意:未定义的变量:DB 在/home/dwscodep/public_html/index.php 第 17 行

警告:mysql_query((:依赖系统的时区设置是不安全的。您需要使用date.timezone 设置或 date_default_timezone_set(( 函数。如果您使用了其中任何一种方法,但仍然收到此警告,则很可能拼写错了时区标识符。我们目前选择了时区"UTC",但请设置 date.timezone 以选择您的时区。在/home/dwscodep/public_html/index.php 第 17 行

警告:mysql_query(( 期望参数 2 是资源,字符串在/home/dwscodep/public_html/index.php 第 17 行给出

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
require_once('lib/config.php');
require_once('blocks/head.php');
$error = array();

if (isset($_POST['signin'])) {
$username = stripslashes(trim($_POST['uname']));
$password = $_POST['pass'];
$password = md5($password);
$sql = "SELECT * FROM ebay_users WHERE username = '$username' and 
password='$password'";
$rs = mysql_query($DB,$sql) or die(mysql_error());
$count = mysql_num_rows($rs);
if ($count > 0) {
while ($row = mysql_fetch_array($rs)) {
$user_id = $row['user_id'];
$user = $row['username'];
$ready_ebay = $row['eBayReady'];
$_SESSION['user_id'] = $user_id;
$_SESSION['username'] = $user;
$_SESSION['eBayReady'] = $ready_ebay;
$_SESSION['signedin'] = true;
$sql = "SELECT * FROM ebay_config WHERE user_id = $user_id ";
//echo $sql;
$resp = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($resp);
if ($count <= 0) {
$sql_insert = "INSERT INTO ebay_config SET 
user_id=$user_id,
title_prefix='New',
profit_percentage = 25,
condition_id = '1000',
price_formula = '001',
dispatch_time = 1,
max_quantity = 1,
shipping_service ='UPSGround',
shipping_type = 'Flat',
payment_method='PayPal',
return_accept_option = 'ReturnsAccepted',
return_days = 'Days_14',
listing_type = 'FixedPriceItem',
listing_duration ='GTC'
";
mysql_query($sql_insert) or die(mysql_error());
}
}
} else {
$error['count'] = '<div id="ErrorMsg" class="alert alert-error">
<button type="button" class="close" data- 
dismiss="alert">&times;</button>
Error! Invalid User Name Or Password
</div>';
$signedin = false;
}
} 

你在这里有几个错误。首先,您需要在文件或 php.ini 文件中设置时区值。那么这个错误

Warning: mysql_query(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function.

会消失。 如果您要将其添加到php文件中,则需要根据您的地理位置添加值,如下所示。对我来说,这是

date_default_timezone_set("Asia/Colombo");

并使用mysqli_而不是mysql,然后您将解决其他一些错误。

最新更新