I turned the entire google upside down and I was unable to find solution for my problem. I have spent 2 months programming a website. I used a PDO connection, but recently switched to Mysqli because PDO started to cause me trouble. I am not so experienced, I think there is solution for the problems that PDO caused me, but I've already spend days trying to figure out how to solve the problems... nothing worked so I switched to Mysqli.
There is just one thing that I need to do in order to complete the conversion of my project from PDO to Mysqli.
$stmt = $conn->prepare("SELECT * FROM users WHERE name = ? AND id = ?");
$stmt->bind_param("si", $categoryname, $categoryid);
$categoryname = "admin";
$categoryid = "13";
$stmt->execute();
$result = $stmt->get_result();
$dsafsdfa = $result[0]['name'];
echo $dsafsdfa;
Of course this code shows me error "Cannot use object of type mysqli_result as array" The fetchall also doesn't work, it also shows me error. Lets say this code is put into a file that is included all over my project. I need to write the code in a way in which it will allow me to set a variable like this:
$dsafsdfa = $result[0]['name'];
I know about the mysqli_fetch_assoc($result);
option but, as i said this file is included all over my project. After the file is included there are always variables are set in this way. If i don't find a way to make the code return me result as an array, i will have to re-code 40% of my project. And my project goes above 30 000 lines of code. Is there a command/option that i don't know that can help me out in this situation? Thank you for your time.