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
3 answers
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
asked Dec 19, 2020 in SQL by Appu (6.1k points)
0 votes
2 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...