0

i am beginner in php . and i have this Sql problem:

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;
}

the error shown is : 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 in this line $result = mysql_query($qry,$this->connection);.

what is the problem? How can i fix it?

4
  • 1
    Could you try it like this mysql_query($qry); It says $this->connection does not refer to a valid mysql-connection link resource Commented May 26, 2013 at 18:31
  • 1
    Check out function where connection to your database is established. Also var_dump($this->connection) so as to check out it's value. Commented May 26, 2013 at 18:31
  • how to know the host from the phpMyAdmin Commented May 26, 2013 at 18:40
  • Shows up on the right hand column, on the top. tinypic.com/r/1scv2a/5 Commented May 26, 2013 at 18:42

1 Answer 1

1

Well, maybe unrelated but i think this needs to be fixed

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

to

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

or

$qry = "insert into user_to_birds(user_id,tax_id)values( 1 ,$id) "
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.