-3

i am using the mysql, the error i think is on the mysql_query because the return false on if condition, this is the code and i cant find the error, the "time" is data-time information sscript

    date_default_timezone_set("America/New_York");
    $now = date("Y-m-d H:i:s") ;

$strsqld = "SELECT 'time' FROM 'tssa_banner_central' WHERE  'time' >  '$now'";


    if($result=mysql_query($db,$strsqld)){echo("ahre");};


    if (mysql_num_rows($result) > 0) {
        // output data of each row
        while($row = mysql_fetch_assoc($result)) {
            echo ($row["time"]);
        };


    }

other script (the require is included)

function connect() {
        $db = mysql_connect( DB_HOST, DB_USER, DB_PASS );
        mysql_query("SET NAMES utf8");
        if (!$db || !mysql_select_db(DB_NAME, $db)) {
            die('***');
            }       
        return $db;
}
  • Possible duplicate of [Can I mix MySQL APIs in PHP?](https://stackoverflow.com/questions/17498216/can-i-mix-mysql-apis-in-php) – Devon Bessemer Jul 06 '18 at 01:20
  • what u mean? the msqli was a error on the paste, fixed – user10039997 Jul 06 '18 at 01:21
  • `date_default_timezone_set("America/New_York").` ? Why the period? You need a semicolon there. – Sam Jul 06 '18 at 01:23
  • @user10039997 Well, you should be using mysqli (or PDO), mysql_* functions are removed in PHP7 and frowned upon. Either way, you aren't checking the value of $result or doing any error handling. – Devon Bessemer Jul 06 '18 at 01:25
  • See the manual page for [mysql_query](http://php.net/mysql_query). The first parameter is the SQL string, and the second is the link identifier. You have them the wrong way around. Also, notice the big red warning notice on that page. You shouldn't be using mysql_* functions anymore. Instead use PDO or mysqli. – Mike Jul 06 '18 at 01:26

1 Answers1

0

replace all mysql with mysqli and mysqli_select_db ( $db , DB_NAME) example: mysql_fetch_assoc with mysqli_fetch_assoc mysql_fetch_array with mysqli_fetch_array

alex
  • 16
  • 5