php

php error_log not getting updated on a MAMP stack

I have MAMP installed on my mac OSX 10.5, php 5.2.11, Apache 2 running phpinfo() from the webserver, shows:- error_log = /Applications/MAMP/logs/php_error_log log_errors = On display_errors = On ini as poining to /Applications/MAMP/conf/php5/php.ini Thinking that there might be a permissions issue. ...

Merging same array values in multidimentional array using PHP

I have this multi-dimentional array: Array ( [0] => Array ( [name] => lorem [id] => 1 [type] => Q1 [q1] => 39.55 [q2] => 0 ) [1] => Array ( [name] => lorem [id] => 1 [type] => Q2 [q1] => 0; ...

How to setup database tables with multiple similar attributes

There are products, sections and attributes. Each attribute can have up to 5 or 6 options. Example: Power 10 Volt 15 Volt 20 Volt And there are about 10 products in total, each product has up to 17 attributes applied to it. Example: Product 1 power - 10 volt color - red, yellow link - online, offline How would you setup the tabl...

Converting timezone offset to friendly name in PHP

I'm trying to convert a RFC timestamp to a friendly date using PHP. Here's the example: Wed, 17 Feb 2010 19:44:01 -0500 I'd like this to print as: Wed, 17 Feb 2010 19:44:01 EST Using date() + strtotime() doesn't seem to do the trick because it converts it to the server's timezone (in my case PST). Is there a simple way to do this ...

Prevent access to files of other users

In my server (cpanel) I see now that with a simple DIR script (PHP) I can list files of all users over public_html /home/[user]/public_html/ How can I prevent users from accessing the files of other users? ...

How can I find one of many possible patterns among a single mySQL entry? More inside.

I had a hard time summing up my question. Basically: There's a table called "files". Files holds an entry called "grades". It is used to identify the particular grade level a file might be useful for. Because a file can be useful for > 1 grade level, I store things like this If it's only good for 3rd grade grades: 3 If it's good for 3...

Problem with a loop inside a PHP SQL statement

Here is my code, part of it is working flawlessly while the other isn't. <?php $query = "Select * from Query ORDER BY time DESC"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { ?> <span class="hotspot" onmouseover="tooltip.show('<center><b><?php echo $row['name'] ?></b></center>');" onmouseout="tooltip.hide...

Using usort in php to sort an array of objects?

I did look at usort, but am still a little confused... Here is what the $myobject object looks like: Array ( [0] => stdClass Object ( [tid] => 13 [vid] => 4 ) [1] => stdClass Object ( [tid] => 10 [vid] => 4 ) [2] => stdClass Object (...

Open file, write to file, save file as a zip and stream to user for download

I'd like if someone could give me some advice on creating this script, which I will add to the existing plug-in (see code below) script below. So what I have now (with the script below) is a means to insert a predefined set of defaults into the wordpress site. What I'm wanting to add, is a helper utility, activated by a button or link t...

Using this inside a static function fails

I have this method that I want to use $this in but all I get is: Fatal error: Using $this when not in object context. How can I get this to work? public static function userNameAvailibility() { $result = $this->getsomthin(); } ...

PHP - lookup array contents with dot syntax

Does anybody see anything wrong with the following function? (Edit: no, I don't think anything is wrong, I am just double-checking since this will be inserted into a very common code path.) function getNestedVar(&$context, $name) { if (strstr($name, '.') === FALSE) { return $context[$name]; } else { $pieces = exp...

Help with optimising calls to the usort function in PHP

This is my callback for my usort() public function sortProperties($a, $b) { $sortA = inflector::camelize(str_replace('-', '_', $this->sortBy)); $sortB = inflector::camelize(str_replace('-', '_', $this->sortBy)); $a = Arr::get($a, $sortA); $b = Arr::get($b, $sortB); if (is_numeric($a) AND is_nu...

How to pass a parameter from a form in Symfony and PHP?

I am trying to implement a very simple search function with PHP in symfony. Basically I have a form that posts a query and I want to retrieve the items in the database that match the query. If I have a User table with columns first_name and last_name, I want to be able to retrieve all items that contain a query. For example, if I submi...

PHP: Call a method on a returned class

I have a method which returns a class and want to call a method on it. Instead of $theClass = $this->getClass(); $theClass->foo(); I would like to write $this->getClass()->foo(); Is there a syntax for this as of PHP4? This works: $this->{$this->getClassName()}->foo(); But I would like to manipulate the class beforehand (I do th...

is there a reason why variable names should be camelCased in the PHP coding standard?

The PHP (PEAR, Zend, etc) coding standard specifies that class names should be in upper CamelCase, while methods and variables (associative arrays keys probably as well) should be in lower camelCase format. The rationale for having classes in CamelCase and underscores is to emulates namespaces and create a parallel with file location, bu...

How can I get a list of a user's networks in Facebook Connect?

Now that Facebook has finally began rolling out the ability for 3rd Party developers to set privacy permissions on objects via Facebook Apps and Facebook Connect I would like to begin implementing these permissions to my Facebook App. http://wiki.developers.facebook.com/index.php/Privacy_(FQL) http://wiki.developers.facebook.com/index.p...

How to run a CodeIgniter file through CRON?

I've tried the following method in the past: <?php set_time_limit(0); $_SERVER['PATH_INFO'] = 'cron/controller/index'; $_SERVER['REQUEST_URI'] = 'cron/controller/index'; require_once('index.php'); ?> and putting this in a file in the codeigniter installation directory, calling it cron.php, and then invoking it via: php /home/[usernam...

How can I dynamically increase a number in PHP

I want to add number dynamically and aiming the outputs as follows. <li data-id="id-1".. > ...</li> <li data-id="id-2".. > ...</li> <li data-id="id-3".. > ...</li> <li data-id="id-4".. > ...</li> <li data-id="id-5".. > ...</li> <li data-id="id-6".. > ...</li> I tried this, but it does not work. Views for($i=1; $i<=$image_num; $i++){ ...

Can I customize the Magento app/code/core folder without affecting future upgrades?

I found a guide on how to add new attributes to users, it explains that for this operation I must modify some files in the app / code / core / Mage directory (the directory that contains Magento’s modules). But if i make some changes in that folder will this affect future upgrades? Will an upgrade will delete my changes? Should I lim...

Can anyone explain why this relative link in php doesn't work?

Hi all, got a strange problem that has so far left me scratching my head. I have an index page with a common.php require file a few folders away. In the require file there are six scripts, with all but two of them being in the same folder as common.php. So for the scripts in the same folder I simply use the file name eg-require('filena...