phpSensei Posted August 5, 2011 Share Posted August 5, 2011 There is no "type" returned here, only the reminder is.... Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252799 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 You need to relax here, its not the query itself but the if condition... just do as 2 of us already told you, var_dump($_GET); edit: Just put it right after "require", it doesn't matter. Thank you, here is the message: array(1) { ["reminder"]=> string( "thisyear" } No conditions metQuerywas empty GET is an HTTP request, that means your URL should look something like: www.mysite.com?reminder=thisyear&type=email Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252807 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 That was my problem. So how would the link look if I wanted both types, call and email? Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252819 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 That was my problem. So how would the link look if I wanted both types, call and email? I spoke too soon...when I change the url I still get an error: array(2) { ["reminder"]=> string( "thisyear" ["type"]=> string(4) "call" } Nothing Here that MatchesQuery was empty Update: helps if I spell "call" correctly! I'm still curious though how the link would look if I wanted to pull both "Call" and "Email"? Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252828 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 It's case sensitive. Call is not the same as call. Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252831 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 Call edit: DAMN IT MAQ, YOUR LIKE A DAMN NINJA.. Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252832 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 It's case sensitive. Call is not the same as call. Caught that...thanks! I'm still curious though how the link would look if I wanted to pull both "Call" and "Email"? What happens if one exists and the other doesn't? Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252834 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 www.mysite.com?reminder=thisyear&type=email So do I need to put some other code into my php or can I just do something like the following? www.mysite.com?reminder=thisyear&type=Emailortype=Call Should I be starting a new post? Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252850 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 you can do http:/www.domain.com/index.php?email=true&call=true Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252851 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 you can do http:/www.domain.com/index.php?email=true&call=true Like this? (I tried both with no luck) www.domain.com/index.php?reminder=thisyear&Call=true&Email=true or www.domain.com/index.php?reminder=thisyear&type=Call=true&type=Email=true Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252859 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 what does your code look like now? You can't still use in_array for this... in_array will match for 1 element, not force the condition to match both, this wouldn't make sense either since type can only be 1 value or the other. using this method www.domain.com/index.php?reminder=thisyear&type=Call=true&type=Email=true change ($_GET['reminder'] == 'thisyear' && isset($_GET['type']) && in_array($_GET['type'], array('Call', 'Email'))) { to (($_GET['reminder'] == 'thisyear') && (isset($_GET['type'])) && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) { Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252860 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 Makes sense, however it didn't work for me, so can you walk me through this (($_GET['reminder'] == 'thisyear') // this I understand && (isset($_GET['type'])) // this checks the variable to see if it's been set && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) // these last 2 is where I'm confused, the column in my table is labeled "type" which we checked above to make sure it's been set. So isn't these last 2 lines of code just asking to check variable "Call" and see if it has "true" in it?{ Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252863 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 edit: fixing your code i sec. My mistake, remove type from the condition put this (($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) { You have to change your query to get Call and Email. Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252864 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 Call edit: DAMN IT MAQ, YOUR LIKE A DAMN NINJA.. Maq = Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252868 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 Here is what I have, it returns no results: (($_GET['reminder'] == 'thisyear') && ($_GET['type'] == "Call") && ($_GET['type'] == "Email")) { $thisyear = date('Y-m-d'); $query = "SELECT * FROM contacttodo,contacts WHERE contacttodo.contacts_id = contacts.ID AND YEAR(reminder) = YEAR(CURDATE()) AND contacttodo.type = 'Email' AND `contacttodo.type = 'Call' ORDER BY contacttodo.reminder ASC"; Since I'm looking for records in this year with Email or Call type I changed to: (($_GET['reminder'] == 'thisyear') && ($_GET['type'] == "Call") && ($_GET['type'] == "Email")) { $thisyear = date('Y-m-d'); $query = "SELECT * FROM contacttodo,contacts WHERE contacttodo.contacts_id = contacts.ID AND YEAR(reminder) = YEAR(CURDATE()) AND contacttodo.type = 'Email' OR contacttodo.type = 'Call' ORDER BY contacttodo.reminder ASC"; Still get no results. Here is my URL: http://www.domain.com/index.php?reminder=thisyear&type=Call=true&type=Email=true Is it the URL thats incorrect because I'm searching for records with Call OR Email? Here is my message on page for the second bit of code with the "OR": array(2) { ["reminder"]=> string( "thisyear" ["type"]=> string(10) "Email=true" } Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252870 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 stop changing my code and use what i provided. Why in the world are you still doing this? Didn't change it for you? didn't i ask you to change? :shrug: :shrug: :shrug: (($_GET['reminder'] == 'thisyear') && ($_GET['type'] == "Call") && ($_GET['type'] == "Email")) { to (($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) { Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252880 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 stop changing my code and use what i provided. Why in the world are you still doing this? Didn't change it for you? didn't i ask you to change? :shrug: :shrug: :shrug: (($_GET['reminder'] == 'thisyear') && ($_GET['type'] == "Call") && ($_GET['type'] == "Email")) { to (($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) { My appologies, I was trying different combos trying to get it to work, I posted it exactly like you said and this is the message I get: array(2) { ["reminder"]=> string( "thisyear" ["type"]=> string(10) "Email=true" } Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252885 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 (($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) { $thisyear = date('Y-m-d'); $query = "SELECT * FROM contacttodo,contacts WHERE contacttodo.contacts_id = contacts.ID AND YEAR(reminder) = YEAR(CURDATE()) AND contacttodo.type = 'Call' OR contacttodo.type = 'Email' ORDER BY contacttodo.reminder ASC"; Thanks again for your help! I will admit to changing the 'AND' to 'OR' after contacttodo.type = 'Call' because I want records with either. Error message: array(2) { ["reminder"]=> string( "thisyear" ["type"]=> string(10) "Email=true" } Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252887 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 your still USING TYPEEEEEEE... Type is gone, Type is now Email.... and Call.. they are 2 different GET values from your HTTP VAr It should look like this, the reason for seperating the variables is so you can have different variations. (($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") &&($_GET['Email']=="true")) { $thisyear = date('Y-m-d'); $todotype = $_GET['type']; $query = "SELECT * FROM contacttodo,contacts WHERE contacttodo.contacts_id = contacts.ID AND YEAR(reminder) = YEAR(CURDATE()) AND (contacttodo.type = 'Email' OR contacttodo.type='Call') ORDER BY contacttodo.reminder ASC"; } Your URL should look like http://www.domain.com/index.php?reminder=Year&Call=True&Email=True Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252888 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 Can you repost the URL, I don't think you meant for it to be http://www.domain.com/index.php?reminder=Year&Call=True&Email=True Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252898 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 Yes, I did mean it to be, this is what you required. It grabs Call or Email or BOTH. Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252904 Share on other sites More sharing options...
iseriouslyneedhelp Posted August 5, 2011 Author Share Posted August 5, 2011 Thank you both sooooo much!! I really learned a lot today from you! Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252907 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 OMG I am so relieved. NP! Quote Link to comment https://forums.phpfreaks.com/topic/243967-php-code-not-working/page/2/#findComment-1252919 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.