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. 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? 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. 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. 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? 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 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.... 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? 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. 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
Archived
This topic is now archived and is closed to further replies.