Jump to content

Php code not working


Recommended Posts

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(8) "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

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"?

 

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

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")) {   

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?{

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" }

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: :shrug: :shrug: :shrug:

 

(($_GET['reminder'] == 'thisyear') && ($_GET['type'] == "Call") && ($_GET['type'] == "Email")) {   

 

to

 

(($_GET['reminder'] == 'thisyear') && ($_GET['Call'] == "true") && ($_GET['Email'] == "true")) {  

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: :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" } 

(($_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" }

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.