cloudll Posted January 20, 2012 Share Posted January 20, 2012 Hi guys, im currently querying my database and if ($row) im including a file. But i would like to make it so if ($row) or a session variable is active, to include the file. I have tried using || but ive only ever used that for regular variables and I cant get it working in the way i want. so at the moment i have if ($row) ( require 'myfile'; and i would like to add || $_SESSION['email'] is active. im guessing i would use isset, but i just cannot get it working. Link to comment https://forums.phpfreaks.com/topic/255438-how-would-i-combine-these-ifs/ Share on other sites More sharing options...
SergeiSS Posted January 20, 2012 Share Posted January 20, 2012 Quote im guessing i would use isset, but i just cannot get it working. You'd better show that code. Link to comment https://forums.phpfreaks.com/topic/255438-how-would-i-combine-these-ifs/#findComment-1309626 Share on other sites More sharing options...
Psycho Posted January 20, 2012 Share Posted January 20, 2012 And please state what the values for $row and $_SESSION['email'] could contain. If you want to do something based upon a session value OR a database result then you should do the Session value check first. If that fails THEN you would do the query. No need to run a query if the session condition is true. Link to comment https://forums.phpfreaks.com/topic/255438-how-would-i-combine-these-ifs/#findComment-1309631 Share on other sites More sharing options...
cloudll Posted January 20, 2012 Author Share Posted January 20, 2012 the value of $row is a post from a form. an email address to check if that email has already been used in the database. and session email doesnt contain anything, it just needs to exist for the require to kick in. Link to comment https://forums.phpfreaks.com/topic/255438-how-would-i-combine-these-ifs/#findComment-1309636 Share on other sites More sharing options...
Psycho Posted January 20, 2012 Share Posted January 20, 2012 Quote the value of $row is a post from a form. an email address to check if that email has already been used in the database. and session email doesnt contain anything, it just needs to exist for the require to kick in. Still not clear. Is $row the value from the form or is it the result from the DB query? Would be nice to see some code. But, based upon my previous statemetn I'd be doing something like this: $includeFile = isset($_SESSION['email']); if(!$includeFile) { //Use form input to run db query and set //$includeFile as appropriate } if($includeFile) { require 'myfile'; } Link to comment https://forums.phpfreaks.com/topic/255438-how-would-i-combine-these-ifs/#findComment-1309646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.