function getCategoryNameById($id) { global $conn; $sql = "SELECT name FROM categories WHERE id=$id"; $result = mysqli_query($conn, $sql); $category = mysqli_fetch_assoc($result); return $category['name']; }
Is getting this error?
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
First of all, your query does not have a terminating semicolon. Not sure if single statement queries go through in php or not. Second, RTFM php.net/manual/en/mysqli.query.php mysqli_query returns false if there's no result or an error, and for some queries, simply returns true. You are the epitome of a php "programmer." You should be ashamed of yourself and should apply for a job as a walmart door greeter
Blake Morris
>query does not have a terminating semicolon why in the fuck do you need terminating semicolon when quering through mysqli_query?
Christopher Fisher
user this is my first time using php. I am not Pajeet.
Noob in need of help.
Lucas Kelly
>using php in 2019 stop >using 2005 php in 2019 Just kys
Brandon Gray
Do you even search for jobs, user? More than 60% of jobs is filled with PHP and JavaScript.
Julian Morales
Wonder if your $conn is fucked put this before your query if (mysqli_connect_errno()) { die "Failed to connect to MySQL: " . mysqli_connect_error(); }
Colton Morales
>not accessing mysql in oop manner $conn = new mysqli($hn, $un, $pw, $db) if($conn->connect_error) die("Fatal Error Faggot");
Luke Thompson
Js yes, php is rare. Even C# is more common. Stop learning a dead language.