-1

When I try to display $time_4 and $time_5, they have no value, they do not display at all nor appear on my screen. I am querying from the right table and the parameters for the query I inputted on $time_1 is all correct and when I run it into my db manually, it gives proper result.

$time_1 = "SELECT * FROM ".ATD_TBL." WHERE nik = '$nik' AND Date = '$date'";
$time_2 = mysqli_query($conn,$time_1);
$time_3 = mysqli_fetch_array($time_2, MYSQLI_ASSOC);
$time_4 = $time_3['clockin'];
$time_5 = $time_3['date'];
Akshay
  • 2,244
  • 3
  • 15
  • 34

1 Answers1

0

try this one

    <?php
$time_1 = "SELECT * FROM `ATD_TBL` WHERE `nik` = '".$nik."' AND `Date` = '".$date."' ";
    $time_2 = mysqli_query($conn,$time_1);
    $time_3 = mysqli_fetch_array($time_2, MYSQLI_ASSOC);
    $time_4 = $time_3['clockin'];
    $time_5 = $time_3['date'];
    ?>
mohammed
  • 26
  • 1
  • 9
  • Hi, I used your code above and this is the result I have http://prntscr.com/bzn460 & http://prntscr.com/bzn5em Should I try changing the variables perhaps? My previous statements above this code use the same format and it works perfectly, just this certain code is not working. – Cyan Hijirikawa Jul 30 '16 at 23:46
  • @CyanHijirikawa Date is a keyword in mysql – mohammed Jul 31 '16 at 00:12
  • thanks for the help. it seems like it still doesn't retrieve anything. it is the same result as the screenshot I have provided above. The ATD_TBL is a constant I defined and it is working properly since the rest of my code is working, just aside from that. http://pastebin.com/umB64hu1 here's the entirety of the code, note the script call at the bottom also doesn't work properly even if i uncomment it – Cyan Hijirikawa Jul 31 '16 at 00:20
  • it has been working for my past queries without any problems though. I'm not sure what happened to that part of the code @mohammed – Cyan Hijirikawa Jul 31 '16 at 00:21
  • read this article it's useful [mysqli_error](http://php.net/manual/en/mysqli.error.php) it's showing how you can use mysqli_error () function to know what type of fault you have – mohammed Jul 31 '16 at 00:45