Jago6060 Posted May 20, 2009 Share Posted May 20, 2009 Trying to do a mysql query via php. Here's the statement... $month = date(n); $day = date(j); $year = date(Y); $sql = "SELECT * FROM pec_mssgs WHERE length(text)>0 AND y=$year AND m=$month AND d>=$day"; Here's the problem: The table I'm searching has a separate field for day, month, and year, so the only way I could think of to get the values for each and match it to today's date, would be by the way I have it set above. Is there an easier way to do this? Currently this thows errors about not being able to jump to different rows. Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/ Share on other sites More sharing options...
fenway Posted May 20, 2009 Share Posted May 20, 2009 Wait, why? Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-838197 Share on other sites More sharing options...
Jago6060 Posted May 20, 2009 Author Share Posted May 20, 2009 Just for the record, I didn't design in any capacity the calendar program or it's mysql database. Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-838268 Share on other sites More sharing options...
fenway Posted May 20, 2009 Share Posted May 20, 2009 Either way, I don't understand why the query wouldn't work. Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-838289 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 What's the error that it throws? Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-838356 Share on other sites More sharing options...
Jago6060 Posted May 31, 2009 Author Share Posted May 31, 2009 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4 This isn't the EXACT error as in copy and pasted, but its essentially the same as what I get. It says it can't jump to row X Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-846454 Share on other sites More sharing options...
fenway Posted June 6, 2009 Share Posted June 6, 2009 So you don't get an error from mysql_query? How are you iterating through the rows? With mysql_fetch_assoc() and a while loop, I hope.... Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-850494 Share on other sites More sharing options...
michael624 Posted June 6, 2009 Share Posted June 6, 2009 Does the word text in --> WHERE length(text)>0 <-- need quotes or '$'? Is this a variable or a constant? Or a row name? Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-850606 Share on other sites More sharing options...
Ken2k7 Posted June 6, 2009 Share Posted June 6, 2009 michael624 - it's probably a column name. Quote Link to comment https://forums.phpfreaks.com/topic/158845-mysql-query-with-multiple-search-conditions/#findComment-850645 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.