php

PHP File Directory - $_SERVER['DOCUMENT_ROOT']'s parent folder

I know $_SERVER['DOCUMENT_ROOT'] returns the document root (most likely something like /home/user/public_html), but is there any way to get the parent directory of this folder? (i.e. just /home/user/) I would try and replace common folder names like public_html or www, but it's not a given that the folder would be named that on all syst...

How can I show session array items in PHP

How can I make something like this below work? <?PHP $_SESSION['signup_errors']['test1']; $_SESSION['signup_errors']['test2']; $_SESSION['signup_errors']['test3']; $_SESSION['signup_errors']['test4']; foreach ($_SESSION['signup_errors'] as $key => &$value) { echo $value; } ?> Warning: Invalid argument supplied for foreach() ...

How can I do this with PHP arrays?

<?PHP $signup_errors = array(); $signup_errors['captcha'] = 'test 1'; $signup_errors['something'] = 'test 2'; $signup_errors['another'] = 'test 3'; $signup_errors['getthepoint'] = 'test 4'; //this would work if (isset($signup_errors) && in_array('test 4', $signup_errors)){ echo 'it works'; } //However I need something like this to...

URL masking in php?

I have a link which is like this: www.domain.com/index.php?var=string1&var2=string2 I want to mask the url to become something like: www.domain.com/index.php, or its best to be like this: www.domain.com I tried google, I found some methods: Using iframe using frameset Mod_rewrite I am using php, IIS and mysql, my server is windo...

PHP ternary operator not working

The code below takes an array value, if it's key exist it should echo out it's value, the ternary if/else part works but the value is not showing up, can anyone figure out why it won't? $signup_errors['captcha'] = 'error-class'; echo(array_key_exists('captcha', $signup_errors)) ? $signup_errors['catcha'] : 'false'; Also where I have ...

Merging File and Post data in PHP

At work I've been dealing with some complex forms (publish pages of Symphony) that contain multiple image upload fields. I need a way to quickly merge $_FILES with $_POST, unfortunately you cannot simply merge the two with array_merge because they don't follow the same structure. Basically if you have $_POST[a][b] it would be $_FILES[a]...

how to do a URL masking in this condition?

I am using php, js, flash and mysql on 1 website. I want to do a URL masking using frameset(or maybe iframe). Scenario: An user click on a link, which direct him/her to my page with this url: www.domain.com/index.php?var1=string1&var2=string2 How to mask the url so that visitor can only see www.domain.com/index.php, but actually ther...

PHP session id's differ

i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe src="load.php"..... i printed out load.php's session id. then i ran another test.php, and printed out it's session id. php session id's were different. therefore, i cannot pass any session variables.... what is happening here ? this problem did not ha...

Transform an array to several sql statements

Hi, I have a array that looks like this Array ( [provider] => Array ( [id] => provider1 [distribuitor] => Array ( [0] => Array ( [name] => distribuitor1 [machines] => Array ( ...

remove "wrapping" array (remove parent, keep children)

Hi, I have a problem, i'd like to remove the containing array (key 80) but keep its children (with all the keys and structure unchanged, apart from the parent). Can somebody help me Array ( [80] => Array ( [parent] => 0 [lng] => en [children] => Array ( ...

Is It Easy to Make an Email Address Book Invite?

Hello, Twitter and Facebook invite new users to send an invitation to everyone in their Gmail, Hotmail, or Yahoo Mail accounts. Is it easy to add this functionality to a website? Thanks, John ...

PHP Equivalant for INET_NTOA and INET_ATON

Are there any PHP equivalents for these two functions? I tried searching but couldn't see anything. Thanks. ...

Save remote img-file to server, with php

Hi, I want to save a remote img-file to my server, but I don't know how to do. The image url is http://img.youtube.com/vi/Rz8KW4Tveps/1.jpg and 1.jpg is to be saved and renamed to imgfolder/imgID.jpg ...

Get next auto increment

I know this isn't so complicated but I can't remember how to do. I just need to know the next auto increment. $result = mysql_query(" SHOW TABLE STATUS LIKE Media "); $data = mysql_fetch_assoc($result); $next_increment = $data['Auto_increment']; ...but i won't work for me, what am I doing wrong? ...

PHP's function to list all objects's attributes

Is there a function to list all object's attributes (like public methods and properties) in PHP similar to Python's dir()? ...

PHP - Displaying page that uses query string, but without any variable

I have a page called Error.php. Variables are usually passed to it using the query string so that it will display the corresponding message to the error code I have assigned. Example: Error.php?id=1 Here is the section of my page below: <?php if($_GET["id"] == "0") { echo "Display certain information..."; } elseif($_GET["id"] == "...

Zend Framework Certification

Hello, I have read the answers to a question asking whether Zend PHP certification is worth the effort: http://stackoverflow.com/questions/165999/zend-php5-certification-does-it-matter I was wondering whether anyone has completed the Zend Framework Certification? Is it worth doing? I know they have a 'Yellow Pages' directory of certif...

PHP: Check whether A Request is GET or POST

This should be an easy one. I have a script, and in the script I want to determine whether the request arrive via GET or POST method. What is the correct way to do it? I am thinking of using something like this if(isset($_POST)) { // do post } else { //do get } But deep in my heart I don't feel this is the right way. Any ...

PHP object class variable

I have built a class in PHP and I must declare a class variable as an object. Everytime I want to declare an empty object I use: $var=new stdClass; But if I use it to declare a class variable as class foo { var $bar=new stdClass; } a parse error occurs. Is there a way to do this or must I declare the class variable as an object...

PHP - Break out of a frame

Is there a way to break out of a frame using PHP? I have done it with JavaScript, but I would really prefer to use PHP instead. Thank you. ...