kernelgpf Posted March 9, 2007 Share Posted March 9, 2007 Very simple code- $tdate=date('h:00:00'); $tday=date('Y-m-d'); $queryed=mysql_query("select bondID,requestingdragon,requesteddragon,outcome from dragonsbonding where endbondingtime='$tday tdate'")or die(mysql_error()); $number=mysql_num_rows($queryed); I've already got a connection to the DB, and tested the variables by printing them out- they are what they should be, and when I test this query in the DB with what the variables are supposed to be, the query fetches results.. but in my script, $number == "0", and I can't figure out why. Any opinions/ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/ Share on other sites More sharing options...
redarrow Posted March 9, 2007 Share Posted March 9, 2007 <?php $tdate=date('h:00:00'); $tday=date('Y-m-d'); $queryed=mysql_query("select bondID,requestingdragon,requesteddragon,outcome from dragonsbonding where endbondingtime='$tday $tdate'")or die(mysql_error()); $number=mysql_num_rows($queryed); ?> Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-203586 Share on other sites More sharing options...
kernelgpf Posted March 9, 2007 Author Share Posted March 9, 2007 ..I omitted by PHP opening and closing for brevity's sake. I know it needs to be there. Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-203592 Share on other sites More sharing options...
kernelgpf Posted March 9, 2007 Author Share Posted March 9, 2007 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-203742 Share on other sites More sharing options...
kernelgpf Posted March 10, 2007 Author Share Posted March 10, 2007 ...please help, someone. Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204010 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 are you sure that this in the database are not a timstamp $tdate=date('h:00:00'); $tday=date('Y-m-d'); $tdate=date('h:i:s');<<<< dont you mean this atleast man lol. Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204024 Share on other sites More sharing options...
kernelgpf Posted March 10, 2007 Author Share Posted March 10, 2007 It is a timestamp- is that a problem? Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204027 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 <?php $date=strtotime(date("y-m-d h:i:s")); $queryed=mysql_query("select bondID,requestingdragon,requesteddragon,outcome from dragonsbonding where endbondingtime='$date')or die(mysql_error()); $number=mysql_num_rows($queryed); ?> <?php $date=strtotime(date("y-m-d h:i:s")); echo date("y-m-d h:i:s" ,$date); ?> Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204029 Share on other sites More sharing options...
Barand Posted March 10, 2007 Share Posted March 10, 2007 ..I omitted by PHP opening and closing for brevity's sake. I know it needs to be there. Did you also notice you omitted the $ from "$tdate" which redarrow included for you? Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204031 Share on other sites More sharing options...
kernelgpf Posted March 10, 2007 Author Share Posted March 10, 2007 Ah, that fixed it, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/41991-query-wont-work-but-when-tested-in-phpmyadmin-it-fetches-results/#findComment-204036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.