thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Part 9 - mysqli_query() warning message #114

Closed ninasmurffh closed 9 years ago

ninasmurffh commented 9 years ago

It's me again, with some more problems. :smile: So I started watching the series from the beginning, working locally on my computer with Xampp this time, and everything was going well until i got to part 9. I inserted the exact same code as in the video, and yes, I've checked multiple times for missing semicolons and other mistakes, but i still keep getting these errors, which i by the way never got working on an external server:

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\projects\Murielia\index.php on line 7

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\projects\Murielia\index.php on line 9

Ps. The dropdown buttons in the navbar don't work either (not sure if that helps) Pps. This is the code in the index.php:

include_once('config/setup.php');

$query = "SELECT * FROM pages WHERE id = 1";
$result = mysqli_query($dbc, $query);

$page = mysqli_fetch_assoc($result);
creptor commented 9 years ago

The error is in the database.... that means that you don't have something to select from the table pages inside your database, please use phpmyadmin and see if i'm correct.

(that could also mean that the db is not defined correctly in the config files -php-)

ninasmurffh commented 9 years ago

I do have a page in the database with the id of 1, and I've checked that I've done everything correctly...

ninasmurffh commented 9 years ago

Problem solved! For some reason I had been using "||" instead of "or" (not sure why XD), so I just changed it to "or" and everything works fine now... Pretty stupid.

creptor commented 9 years ago

but how did that affect that code? it was like inside an if statement? please anwser that

ninasmurffh commented 9 years ago

@creptor I honestly have no idea, I just thought nothing was going to change but obviously it did. When I googled it, I found out that or has a lower precedence than ||, but I don't even know what that means exactly :laughing: