Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从临时表中选择时出错_Php_Mysql - Fatal编程技术网

Php 从临时表中选择时出错

Php 从临时表中选择时出错,php,mysql,Php,Mysql,在临时表中进行选择时出现以下错误: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given $row_checkbanned = mysql_fetch_assoc($query_checkbanned); 以下是完整的代码: mysql_select_db($database_config, $config); $query_temptable = "CREATE TEMPORARY TA

在临时表中进行选择时出现以下错误:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given 

$row_checkbanned = mysql_fetch_assoc($query_checkbanned);
以下是完整的代码:

mysql_select_db($database_config, $config);
$query_temptable = "CREATE TEMPORARY TABLE IF NOT EXISTS temp (
id int NOT NULL AUTO_INCREMENT,
player_id int(11) NOT NULL,
team_id int(11) NOT NULL,
newteam_id int(11) NOT NULL, PRIMARY KEY(id))";
$Result1 = mysql_query($query_temptable, $config) or die(mysql_error());


for($i=0; $i < count($_POST['id']); $i++){
$p_id=mysql_real_escape_string($_POST['id'][$i]);
$t_id=mysql_real_escape_string($_POST['hometeam'][$i]); 
$nt_id=mysql_real_escape_string($_POST['teamID'][$i]);
$insertSQLban = "INSERT INTO temp (player_id, team_id, newteam_id) VALUES ('$p_id', '$t_id', '$nt_id')"; 
mysql_select_db($database_config, $config);
$Result1 = mysql_query($insertSQLban, $config) or die(mysql_error());}


$query_checkbanned = ("SELECT temp.player_id FROM temp, f_banned WHERE f_banned.banplayer_id = temp.player_id AND f_banned.bteam_id = temp.team_id GROUP BY temp.player_id ORDER BY temp.player_id ASC");
$checkbanned = mysql_query($query_checkbanned, $config) or die(mysql_error());
$row_checkbanned = mysql_fetch_assoc($query_checkbanned);
$totalRows_checkbanned = mysql_num_rows($checkbanned);    
mysql\u select\u db($database\u config,$config);
$query\u tentable=“如果不存在临时表,则创建临时表”(
id int非空自动增量,
玩家id int(11)不为空,
团队id int(11)不为空,
newteam_id int(11)不为空,主键(id))”;
$Result1=mysql\u query($query\u tentable,$config)或die(mysql\u error());
对于($i=0;$i

哪里出错?

您将错误的参数传递给了
mysql\u fetch\u assoc
mysql\u num\u rows

$checkbanned = mysql_query($query_checkbanned, $config) or die(mysql_error());
$row_checkbanned = mysql_fetch_assoc($checkbanned);
$totalRows_checkbanned = mysql_num_rows($row_checkbanned);  

尝试
$row\u checkbanked=mysql\u fetch\u assoc($checkbanked)将结果资源(从代码> MySQLyQuices()返回到<代码> MySQLYFETCHCHYAXOSO()/代码>。您通过了SQL字符串。同时,请回顾并考虑切换到支持准备好的语句的API,如MySQLI或PDO。旧的代码> MySQL**()
函数现在已弃用,将在即将发布的版本中从PHP中删除。非常感谢,我多次检查代码,但没有看到此错误!