0

我是 php 的初学者。我有这个 Sql 问题:

function InsertUserBirdsFromFile($File_content){
for($i =0; $i < count($File_content); $i+=2){
$id = $this->Master_file($File_content[$i], $File_content[$i + 1] );
if(isset($id)){
try{
$qry = "insert into user_to_birds(user_id,tax_id)values( 1 ,'.$id .') ";
         $result = mysql_query($qry,$this->connection);

}
catch(Exception $ex){ echo  $ex;}
}
}
}

function Master_file($name, $latin ){
try{

 $qry = "SELECT tax_id FROM  master where name =".$name." and latin =".$latin;
         $result = mysql_query($qry,$this->connection);
        }
        catch(Exception $ex){ return null;}
                        if ($result == true && mysql_num_rows($result) >0) {
                        $p=0;
                          while ($Res_user = mysql_fetch_array($result) ) {
                        $marques[$p] = $Res_user;
                        $p++;
                        }
                        return $marques[0]['tax_id'];
                        }
                        else return null;
}

显示的错误是:Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/admin/public_html/hitlist/include/fg_membersite.php on line 427 在这一行$result = mysql_query($qry,$this->connection);

问题是什么?我该如何解决?

4

1 回答 1

1

好吧,也许不相关,但我认为这需要解决

$qry = "insert into user_to_birds(user_id,tax_id)values( 1 ,'.$id .') "

$qry = "insert into user_to_birds(user_id,tax_id)values( 1 ,".$id .") "

或者

$qry = "insert into user_to_birds(user_id,tax_id)values( 1 ,$id) "
于 2013-05-26T18:33:20.267 回答