php

Can you unset() many variables at once in PHP?

I have a pretty high traffic social network site, I would like to get into the habit of unsetting large array and mysql object and even some string variables. So is it possible to unset more then 1 item in PHP example: <?PHP unset($var1); // could be like unset($var1,$var2,$var3); ?> ...

How Can I Authenicate Users of my API

A website that I co-own has been asked us to add some content to our site which is great advertising for us. The catch is that because of the nature of our company, we have to be very careful about who has access to our site. (We distribute music for labels to radio stations) Following so far? So I have started a new page for the conte...

Passing variables across a multi page form in php

Forgive me as I am a newbie. I have a multi page form in which I am using $_SESSIONS to record the variables. <?php session_start(); foreach ( $_POST as $key=>$value ) { if ( $key!="submit" ) { $value= htmlentities(stripslashes(strip_tags($value))); $_SESSION[$key] = $value; } }` I have two problems actually. W...

PHP Email Form

Could anyone tell me if there is something wrong with the code or a better way to modify it? for some reason when i hit submit on my contact form it displays the "error.html" page but i still get an email sent to my account. $EmailTo = "[email protected]"; $Subject = "Contact Submission"; $Name = Trim(stripslashes($_POST['name'])); ...

To understand PHP sessions with sub-arrays better

How can you see the assigned value of the following SESSION variable? I run the following after start_session() $_SESSION['login']['email'] = "ntohuh"; I get after printing with print_r($_SESSION); ( [login] => Array ( [email] => ) This question is based on this thread. ...

Strict xml validation in php

I'm trying to fully validate an xml file which may be published by a user before it's fully published and live - it's basically somewhat like a sitemap.xml and it absolutely can't be published without being error-proof ( yes, I do have my own custom dtd for it as well ). I was also thinking of implementing a storage system so it would s...

Why is the PHP get_headers() Last-Modified different from the apache file info

I have an Apache directory listing of files on a remote server (in Australia/Adelaide +930) I have no control over. This server shows the correct last modified date of a file as: 14-Aug-2009 09:41 I have a PHP script on my US server to check the date of the remote file. get_headers()['Last-Modified'] returns: Fri, 14 Aug 2009 00:11:11 G...

How do I save the original argument in a recursive function in PHP?

Hi, I'm in PHP working on an Euler problem. I have this function so far: <?php $biggest = 0; $counter = 1; function test($i){ global $biggest; global $counter; if ($i == 1) { echo "I'm done! Took me $biggest steps"; } else { if ($i%2 == 0) { $counter = $counter + 1; if ($counter>$biggest) { ...

Suppressing errors beyond setting ERROR_REPORTING ( display_errors perhaps? )

Let's say I'm basically inheriting a live site that has a lot of errors in production, I'm basically doing a recode of this entire site which might take a month or so. There are some cases in which this site was reliant upon external xml file feeds which are no longer there, but the code wasn't properly setup to supply a nice clean err...

To visualize the sequence of PHP codes

Is there any tool by which you can visualize the sequence of PHP code such that you can avoid mistakes such as here? I had an idea that the code later in my PHP code will overwrite the code at the beginning. However, this was not the case in my case. ...

PHP: Cannot redeclare function error?

<?php function date($x) { $contents = $_FILES['userfile']['tmp_name']; $contents = file("$contents"); $date = $contents[$x][6].$contents[$x][7]."-".$contents[$x][8].$contents[$x][9]."-"."20".$contents[$x][4].$contents[$x][5]; return $date; } ?> Fatal error: Cannot redeclare date() in .../includes.p...

Problem with prototype framework in cake php

This question is somewhat related to my previous question (not necessary to go through it) link text , although this one is more of an Ajax problem. I tested my page in firebug and I am getting the following error Event.Observe is not a function Event.observe('form908983160', 'submit', function(event) { new Ajax.Updater('comments','/...

Finding IP address of client connected through a proxy

Hi guys, Is there a way to collect the IP address of a client connected to your website through a proxy server? The entire setup is an internal LAN and through the sysadmin, I have control over the proxy machine as well. I am using PHP5 for the website server side. I tried $_SERVER['REMOTE_ADDR'] in PHP but this variable just stores t...

Uploadify plugin

Has anyone used this plugin? I don't know if my setup is right, but I think so.. $(document).ready(function() { $("#uploadify").uploadify({ 'uploader' : '/extra/flash/uploadify.swf', 'script' : '/admin/uploads/artistsphotos', 'checkScript' : '/admin/uploads/artistsphotos', 'cancelImg' : '/images/cancel.png', '...

How to implement OOP Efficiently

Hi all, Can anyone tell me how to implement OOP efficiently in PHP? Thanks Fero ...

file_get_contents(): No such host is known error

hi experts, when i am using file_get_contents function to get the url in to string i am getting the following error. how can i solve this in my localhost ? $contents = file_get_contents("http://google.com"); file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known. than...

PHP: Variable Scope Question/Referencing Variables

<?php function table() { ot(); for($x=0; $x<$rows; $x++) { table_row($x); } ct(); } ?> Notice: Undefined variable: rows in .../scratch.php on line 12 Hi, This function is returning an error because $rows is not defined locally. I define the variable $rows in another php script, which is referenced via "includes...

Why does mysqli_close fail after calling apc_fetch on a stored ArrayObject?

The following code; //... connect to mysqli database $xyz = array(); $xyz[] = new Object(); $xyz[] = new Object(); apc_store("xyz", new ArrayObject(xyz), 600); $xyz = apc_fetch("xyz"); mysqli_close($link); causes mysqli_close to throw; Error Type: mysqli_close() [function.mysqli-close]: Couldn't fetch mysqli (WARNING) I need to sto...

Php, update password without login?

I have a new website. And the following is my scenario: I will send an email to 5 people (numbers not important), inside the email, i will include a link for them to click: www.domain.com/[email protected]&key=abc...xyz They key are randomly generated using salt and sha1 in php. Upon click the link in their email, can I directly let t...

PHP: "non well formed numeric value encountered"

<?php function aum($x) { $contents = $_FILES['userfile']['tmp_name']; $contents = file("$contents"); $aum = $contents[$x][13].$contents[$x][14].$contents[$x][15].$contents[$x][16].$contents[$x][17].$contents[$x][18].$contents[$x][19].$contents[$x][20].$contents[$x][21].$contents[$x][22].$contents[$x][23]; $faum = money_format('%(#1n',$...