Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am executing the below code.

$result = mysqli_query($con, "SELECT classtype FROM learn_users WHERE username='abcde'");

echo "my result <a href='data/$result.php'>My account</a>";

I am getting the following error:

 Object of class mysqli_result could not be converted to string 

1 Answer

0 votes
by (12.7k points)
edited by

The mysqli_query() method will be returning an object resource to your $result variable, not a string value.

You have to loop it up and then access the records. Because you directly can not use it as your $result variable.

while ($row = $result->fetch_assoc()) {

    echo $row['classtype']."<br>";

}

 Want to know more about SQL ? Join this SQL Certification course by Intellipaat.

Related questions

0 votes
1 answer
asked Dec 22, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Jan 8, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Jan 3, 2021 in SQL by Appu (6.1k points)
0 votes
3 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...