troubleshooting Question

If MYSQLi result = "0", include x...

Avatar of nikaotech
nikaotech asked on
14 Comments1 Solution456 ViewsLast Modified:
Hello Experts,

I'm trying to dynamically place one of two menus on a page based on the result of a select statement.  It's actually working, but it's also throwing a couple of errors at the same time.  I am basically checking to see if the value of "dependent_id" is "0" or not.  That field is an integer with values from 0-12. If the value is "0" I need to include "menu1.php".  If it's anything else, "menu2.php".  The determination of which menu to use is working correctly, but as I mentioned, it's also throwing these two errors:

Error 1:
Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, string given on line:

Error 2:
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, string given on line:

Here is that entire section...
 $host = "localhost";
 $username = "user";
 $password = "pass";
 $db_name = "db";
 $db = new mysqli($host, $username, $password, $db_name);
 if(mysqli_connect_errno()) {
     echo "Error: Could not connect to database.";
		$query="select dependent_id from clients WHERE client_id='".$mysqli->real_escape_string($_REQUEST['client_id'])."'";
		$result = $db->query($query);

				if($result = "0"){

Many thanks for any help!

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros