php

php quits connecting to Oracle

We've got an ongoing issue where php 5.2.6 will quit connecting to Oracle 10.2.0.4.0. We can go weeks without any issues and then (usually Saturday mornings) php will no longer be able to connect. The database is up and running and we can connect to it manually with varous DB tools but php won't ever connect again until we reboot the web...

curl cookie problem in PHP

hi as my client needs, I developed a code to login via cURl. login to www.web1.com and store cookies in cookie.txt go to www.web2.com and browse a page using that cookie.txt no problem with www.web2.com so when i want to do this with www.web3.com, the problem appears. the www.web3.com uses session and cookies itself and I have to...

Sorting array problem in PHP

I have the following array [0] => Array ( [id] => 229 [val] => 2 ) [3] => Array ( [id] => 237 [val] => 1 ) [4] => Array ( [id] => 238 [val] => 6 ) I need to sort this array according to the val values in th...

Header order question in PHP (and HTTP in general)

Is there a particular order in PHP to set HTTP headers with the header() function ? I mean for example must I call header('Content-Language: en'); before header('Content-Type: text/plain'); or whathever order will be OK. My guess is that order isn't important as long as all he headers are set before any content outputted, but I just wa...

How to explain 'this' keyword in a best and simple way?

I am using 'this' keyword for a long time. But when someone asks me to explain it, I am confused that how to explain it. I know that I can use this in a method of class to access any variable and method of the same class. class MyClass{ function MyMethod1(){ echo "Hello World"; } function MyMethod2(){ ...

Getting Started with SAML and PHP

I'm beginning work on adding SAML SSO support to a project and am looking for any helpful resources specifically geared towards PHP. I understand the basic concepts and have poked around for any libraries that could help but have come up empty. The only thing I've found is simpleSAMLphp which appears to be an entire stack. Any tips for ...

PHP Traversing Function to turn single array into nested array with children - based on parent id

I have an array similar to this: Array ( Array ( [ID] => 1 [parentcat_ID] => 0 ), Array ( [ID] => 2 [parentcat_ID] => 0 ), Array ( [ID] => 6 [parentcat_ID] => 1 ), Array ( [ID] => 7 [parentcat_ID] => 1 ), Array ( ...

user activity database structure

Hello. I am working on a community website. I want to show the user's activity in 2 places in the website. The User "A" Profile. The Friends page of the user "A" friends. "What are your friends doing?" The tables for instance are: members members_gallery members_videos members_friends my problem is in the Sql structure. I've ...

File Download Not Working

When I download the original zip it works fine, but when I download it using the below headers and stuff it doesn't work. I know it's better to take this route and tell the browser how to handle the file rather than leave it up to the browser, but I can't get this to work, so I'm tempted to use a header() forward. $path = $...

Custom authentication handlers in phpBB3 issue: logging in but not saving to session

Hello, I'm creating a custom authentication handler in phpBB3 so that it's integrating into an existing website, and so members don't have to log into and create accounts on both the main site and the forum area. I've taking the existing DB authentication file auth_db.php, copied it, renamed it auth_whb.php, and set that as my authenti...

Good way to create script supporting translations?

Hello I'm creating an open-source cms and was just wondering that which is the best way to add localizations? I already decided to have them in files similar to lang.en.php. I would assume arrays, but in which form? $lang['xyz'] = "Text goes here!"; $lang['Text goes here!'] = "Translated text!"; Or should I create my custom parser an...

Parse error when run by cron but not from command line?

So I have a cronjob which executes a PHP script like so: 0 0 * * * /usr/local/bin/php -f /home/mysite/mysite.com/cronjobs/renewal_email.php If I issue the same command from the command line it runs without error and running with the l flag shows no syntax errors. However cron emails the following: Parse error: syntax error, unexpec...

PHP regex replace white space by   if it is following single letter

Hi, I have user defined string (html formated string to be saved and used in web) and need to find a way to replace each white space which is right after a single letter by  . For example "this is a string" should become "this is a string", "bla bla b l abla b la blabla" should become "bla bla b l abla b la b...

The first day of the current month in php using date_modify as DateTime object

I can get Monday this week with: $monday = date_create()->modify('this Monday'); I would like to get with the same ease the 1st of this month. How can I achieve that? Thanks ...

Netbeans: PhpDoc formatting

How to automatically format PhpDoc comments in Netbeans? I'd like to have comments aligned like this: * @author Author Name <[email protected]> * @package Doctrine * @subpackage Table * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision: 67999 $ * @link www.phpdoctrin...

Passing parameters to PHPUnit

I'm starting to write PHPUnit tests and I'd like the tests to be run from developers machines as well as from our servers. Developers machines are set up differently than the servers and even differently from each other. To run in these different places it seems to be the person that runs the test is going to have to indicate where it'...

SQL error in php

Hey, I wrote some code for extracting some information out of the database and checking to see if it met the $_COOKIE data. But I am getting the error message: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 My code so far is: $...

PHP session_cache_limiter() private and nocache HTTP Expires date question

If you look at the PHP doc help for function session_cache_limiter(), you will see that if the cache_limiter parameter is set to private or nocache the Expires HTTP header is set to a const date (Thu, 19 Nov 1981 08:52:00 GMT). I understand that this is a date in the past to avoid caching, but why this date/time in particular? It's not t...

How do you change the timezone in PHP for an existing timestamp?

The code for the date and time function: function date_and_time($format,$timestamp) { $date_and_time = date($format,$timestamp); return $date_and_time; } And then the code to display it: <?php echo date_and_time("dS F Y", strtotime($profile[last_activity_date_and_time])); ?> The value of $profile[last_activity_d...

PHP as FastCGI and exit() function

How exactly is exit() function working when in fastcgi mode? does it finish whole instance of php process in fastcgi pool or just ends current request and return process to te pool? if the second answer - what causes logs of this kind: [warn] FastCGI: (dynamic) server "/php.fcgi" (pid 25113) terminated by calling exit with status '0' ...