corbeeresearch Posted November 20, 2010 Share Posted November 20, 2010 First of all, I'm not used to using database without codeigniter, though it is working fine, I kept receiving a warning message. Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in XXXXXXX on line 69 result: 6Error, message already sent What am I doing wrong to prompt this warning? this is my code <?php include('config.php'); $nineyesterday =date( 'Y-m-d H:i:s', mktime(date("H") - (date("H") + 3), date("i") - date("i"), date("s") - date("s"), date("m") , date("d"), date("Y")) ); $ny10pm =date( 'Y-m-d H:i:s', mktime(date("H") - (date("H") + 3), date("i") - date("i") + 10, date("s") - date("s"), date("m") , date("d"), date("Y")) ); $now = date('Y-m-d H:i:s'); $nineam = date('Y-m-d 09:00:00'); $ninepm = date('Y-m-d 21:00:00'); $nine10am = date('Y-m-d 09:10:00'); $nine10pm = date('Y-m-d 21:10:00'); echo '9pm yesterday: '.$nineyesterday; echo '<br/>'; echo '9am: '.$nineam; echo '<br/>'; echo '9pm: '.$ninepm; echo '<br/>'; echo 'now: '.$now; echo '<br/>'; /** * If statement inside if statement, check if record exists in the database, * if not available, insert and send email * if exists do nothing. * * */ if ((strtotime($now) > strtotime($ny10pm)) && (strtotime($now) <= strtotime($nine10am))) { //count the answers by yes or no echo 'yesterday at 9pm till today at 9am '.'<br/>'; //query the date if doesn't exist insert the date and do the query $date = "SELECT count(date) FROM t_date WHERE date = '".$nineam."'"; $istrue = mysql_query($date); while($row = mysql_fetch_array($istrue)) { $istrue = $row['count(date)']; } echo "result: ".$istrue; if ($istrue == 0) { $q = "SELECT opt, count(opt) FROM plus_poll_ans WHERE date BETWEEN '".$nineyesterday."' AND '".$nineam."' GROUP BY opt desc "; $subject = "Confessions from ".$nineyesterday." to ".$nineam; $flagdate = mysql_query("INSERT INTO t_date(date) values('".$nineam."')"); echo "<br/> successful <br/>"; } else { exit('Error, message already sent'); } // else exits } elseif ((strtotime($now) > strtotime($nine10am)) && (strtotime($now) <= strtotime($nine10pm))) { //count the answers by yes or no echo 'today at 9am to 9pm'.'<br/>'; //query the date if doesn't exist insert the date and do the query $date = "SELECT count(date) FROM t_date WHERE date = '".$ninepm."'"; $istrue = mysql_query($date); while($row = mysql_fetch_array($istrue)) { $istrue = $row['count(date)']; } echo "result: ".$istrue; if ($istrue == 0) { $q = "SELECT opt, count(opt) FROM plus_poll_ans WHERE date BETWEEN '".$nineam."' AND '".$ninepm."' GROUP BY opt desc "; $subject = "Confessions from ".$nineam." to ".$ninepm; $flagdate = mysql_query("INSERT INTO t_date(date) values('".$ninepm."')"); echo "<br/> successful <br/>"; } else { exit('Error, message already sent'); } exit; } Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/219283-problem-with-mysql_fetch-array/ Share on other sites More sharing options...
corbeeresearch Posted November 20, 2010 Author Share Posted November 20, 2010 Nevermind, I realized that I'm overwriting the loop. Thanks for everyones time. Quote Link to comment https://forums.phpfreaks.com/topic/219283-problem-with-mysql_fetch-array/#findComment-1137118 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.