0

I'm trying to try and check if a value is equal to one,

variables.php

<?php
  $server = "localhost";
  $username = "root";
  $password = "xxxx";
  $dbName = "website2";

  $link = mysql_connect($server, $username, $password, $dbName);

  $maintenanceMode = mysqli_query($link, "SELECT * FROM website_checks WHERE maintenanceMode = '1'");
?>

index.php

<?php
  include 'mysql/variables.php';
?>

<?php
  if ($maintenanceMode == '1') {
     echo "hello";
  } else {
     echo mysql_error();
  }
?>

I get no error. Please help?

thanks inadvance!

  • How do you expect to get errors, if you don't check for them? Also you probably want to count the [num. of rows](http://php.net/manual/en/function.mysql-num-rows.php). – Rizier123 Jul 20 '15 at 10:44
  • Oh. Well I got errors before then I added `$link` to `$maintenanceMode` then I didn't get errors. – user3765978 Jul 20 '15 at 10:50
  • Turn on error reporting and check if your connection fails or your query. And then you will get some errors. – Rizier123 Jul 20 '15 at 11:01
  • Okay so, I've checked for num_rows and it returns the integer `1` which I have inserted into my database. – user3765978 Jul 20 '15 at 11:05
  • Your first and main problem is, that you are mixing MYSQL API's, which you can't mix. So you have to decide for an API. (And I would recommend you `PDO` or `mysqli_* prepared statements`; `mysql_*` is deprecated and will be removed) – Rizier123 Jul 20 '15 at 11:13

0 Answers0