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.
Andrew Brooks
I have that in config.php and included confi.php in my page. Definitely connected to the db. I have another page that displays all published pages, trying to do this page to display posts by category.
Austin Rodriguez
>php is rare nope! Almost any web dev. job requires you to have the knowledge of php and js with at least efficient in one framework of a given language.
Noah Johnson
Legacy systems only Have fun maintaining 20 year old shit Python is where it's at (also js for backend but fuck that shit language)
Brayden Howard
>also js for backend but fuck that shit language yes!
Isaac Stewart
Updating wordpress is not a web dev job
Wyatt Reed
yet it was too hard to read the return values. Also procedural and non prepared statements.
Literally kys
Jaxson Foster
But laravel is fucking comfy.
Ethan Sanchez
Die in a fire faggot.
Parker Richardson
sweet sanitized input
Juan Jones
>laravel The whole Facade stuff really makes for bad maintainable code. Symfony is where it's at.
Julian Wright
mysql_query was deprecated in php 5.5 (2013) and removed in 7.0 (2015).
Xavier Walker
He's got a point though. If you can't solve shit like this in one minute by googling or reading the basic, most simple documentation on the matter you're using the wrong language or you're in the wrong field.
Asher Bailey
True
Evan Howard
getCategoryNamebyId("1 UNION ALL SELECT * FROM users");
Dylan Long
OP is using the replacement for it, mysqli_query.
Chase Cooper
>If you can't solve shit like this in one minute by googling or reading the basic, most simple documentation on the matter you're using the wrong language
No other language will solve the problem here. At least he's not writing JS and having functions return Promises and fuck with him.
as in many other programming languages, php has a specific rule set written in the documentation.just like Jow Forums, and you know what the rules are in Jow Forums? clearly not.
here is a good rule: Jow Forums is NOT your personal tech support team or personal consumer review site.
funny aint it? just reading the rules... maybe read the god damn documentation faggot
Andrew Cooper
Wpw thanks, nice to know there are genuine helpfull people still left in this world.
Thanks for your help user.
Josiah Rogers
>phone posting >sarcastic bitch response you have to go back. also, drop php and go with python and use some shitty library that supports cursor objects, it'll be easier for you. there's still documentation for you to read though which will complicate things because you're an illiterate nigger, but it beats php in this case