isset

How can I get insert query to work with two if(isset statements?

On a users profile, there is a comment box that enables other users to post comments on their profile. I am now working on a dynamic comment area that has a changing text box depending on if A. you are looking at your own profile B. looking at someone elses profile C. not signed in at all. I am trying to implement "updates" now when you...

PHP isset($this) and using the same object method in a static and object context

I'm working on a class which needs to be accessible via static function calls as well as object methods. One thing I have found is that I'm duplicating logic across multiple functions. Simplified example: class Configurable{ protected $configurations = array(); protected static $static_configurations = array(); public fu...

Why do I need the isset() function in php?

I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something } and if ($_POST['Submit']) { //do something } It seems to me that if the $_POST['Submit'] variable is true, then it is set. Why would I need the isset() function in this case? ...

isset and !empty not passing through a check for uploaded files

I have an upload form with a file to be uploaded. The issue I have is that even when no file is uploaded the if(isset($_FILES)) OR if(!empty($_FILES)) still passes as successful: $_FILES = $HTTP_POST_FILES; if($_POST['type'] == 'photo' && isset($_FILES)){ // returns true even if no file is uploaded. What am I missing! } ...

Check if an array item is set in JS

Hi, I've got an array var assoc_pagine = new Array(); assoc_pagine["home"]=0; assoc_pagine["about"]=1; assoc_pagine["work"]=2; I tried if (assoc_pagine[var] != "undefined") { but it doesn't seem to work I'm using jquery, I don't know if it can help Thanks ...

Using php's magic function inside another function does not work

I want to use magic function __set() and __get() for storing SQL data inside a php5 class and I get some strange issue using them inside a function: Works: if (!isset($this->sPrimaryKey) || !isset($this->sTable)) return false; $id = $this->{$this->sPrimaryKey}; if (empty($id)) return false; echo 'yaay!'; Does not work: if (!isset(...

PHP reading 'get' variable that may or may not have been set

Simply put, if you try to read the value of a get variable, what happens if said variable had not be put into the URL. Example: you request the page test.php, in that file it tries to read the value of $_GET['message']. What happens in this case? dose the value just get returned as ''? Dose this mean, that if I am always expecting a val...

[Smarty] Looking for variables which aren't assigned.

What could happen if my template looks for variables which weren't assigned? For example: var id = '{$tpl_id}'; This snippet is from my javascript code. I outputted the value and it is simply empty. I know I could use isset(). But I couldn't find anything about how Smarty handles non-existing variables. So, what happens if a template...

isset code not being executed PHP

I was wondering if my code below is even correct, I've been having numerous errors with this, but am not sure if the problem really exists here. The code is below: The user will click 'Exit Group'. <p class="logout"><a id="exit" name="logout" href="#">Exit Group</a></p> The code that should be execute when 'Exit Group' is clicked is ...

php - test if sessions are started

How do you test to see if sessions are on. This is not the way... <?php session_start(); if(isset($_SESSION)) { echo "sessions ON<br>"; } else{ echo "sessions OFF<br>"; } session_destroy(); if(isset($_SESSION)) { echo "sessions ON<br>"; } else{ echo "sessions OFF<br>"; } ?> ...

php: difference between to isset methods?

hey guys, not sure how i should name the title of the post. i'm having a submitbutton on my page that's creating a folder for me. as soon as i press it. the site AUTOMATICALLY refreshes. There's no script set in my document that says the page should refresh. it just happens when i submit anything, right? if (isset($_POST['createDir'])...

PHP object isset and/or empty

Is there a way to check if an object has any fields? For example, I have a soap server I am querying using a soap client and if I call a get method, I am either returned an object containing fields defining the soap query I have made otherwise I am returned object(stdClass)#3 (0) { }. Is there a way to tell if the object has anything? ...

PHP: How do you check if the variable passed as an argument is set ?

I want to check if a variable called $smth is blank ( i mean empty space ), and i also want to check if it is set using the function i defined below: function is_blank($var){ $var = trim($var); if( $var == '' ){ return true; } else { return false; } } The problem is i can't find a way to check if variab...

what is slower or what is faster in PHP: if( @$myvar['test'] === null ) or if( !isset( $myvar['test'] ))

I wonder what is slower or faster: if( @$myvar['test'] === null ) { .. } or: if( !isset( $myvar['test'] )) { .. } Also wondering if you suppress a warning or notice with @, will it make the evaluation slower? Thanks for your answer! PS: It is not about the difference, i know that isset checks if a element is set and not if it is ...

Check if value isset and null

Hi, I need to check if value is defined as anything, including null. isset treats null values as undefined and returns false. Take the following as an example: $foo = null; if(isset($foo)) // returns false if(isset($bar)) // returns false if(isset($foo) || is_null($foo)) // returns true if(isset($bar) || is_null($bar)) // returns true...

Passing parameters back to same form using PHP

I am trying to simply set a variable and have it passed back to the same PHP script as called, however it doesn't work. The first time the script is run I see what I expect to see on screen which is Your store is USA and your language is en If I then choose UK and press submit I see the following line Your store is and your ...

PHP: Check if variable exist but also if has a value equal to something

PHP Question: Hi there, this is just something I was wondering today, what I'm doing: I have (or not) a variable $_GET['myvar'] coming from my querystring and I want to check if this variable exists and also if the value corresponds to something inside my if statment: What I'm doing and think is not the best way to do: if(isset($_GET...