php

Server allowing only one request per session

Scenario: All pages of xyz.com use sessions to check if I am logged in and display customized content. I am logged into xyz.com using Firefox on my iMac. Now, when I try to visit, xyz.com/page1.php and xyz.com/page2.php at the same time, until page1 loads page2 is not processed. Code Samples xyz.com/contains (links): /* session che...

How to set a reference inside PHP function?

I am trying to set a reference in a function. But, I am not able to get this working. Code I tried: function set(&$x, &$y) { $x =& $y[2]; } $y = array( 0, 1, array('something') ); $x = array('old_val'); print "1. inited, x is:\n"; print_r($x); set($x, $y); print "\n2. now, x is: "; print_r($x); Output: 1. inited,...

Emulating named function parameters in PHP, good or bad idea?

Named function parameters can be emulated in PHP if I write functions like this function pythonic(array $kwargs) { extract($kwargs); // .. rest of the function body } // if params are optional or default values are required function pythonic(array $kwargs = array('name'=>'Jon skeet')) { extract($kwargs); // .. rest of t...

SoapFault exception: [VersionMismatch] PHP Zend

Hi ALL~ I'm getting this error while I was implementing and testing PHP webservice using Zend Soap. I'm testing the same codes under 2 different protocols(http & https) in 2 different web servers. http site works just fine, but I get "SoapFault exception: [VersionMismatch]..." error in https. The two web servers almost have the same s...

Examples of good php code.

Duplicate Good open source PHP projects What is the best open source application written in PHP to reference for ‘good code’? What are your favorite examples of well-coded PHP applications? [closed] I'm php newb. I want to explore code of more experienced programmers. Please advise open source php projects which have exam...

using shared memory with php and c?

Can you use shared memory to communicate between php scripts and c program in windows? The c program runs all the time and uses memory mapped files ie: handle1 = CreateFileMapping( (HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(byte)*BUFFER_SIZE, "my_foo" ); hView = (LPINT) MapViewOfFile(handle1, FILE_MAP_ALL_ACCESS, 0, 0, 0); ...

php get variables as key with no value assigned

If I enter the following into the browser: http://domain.com/script.php?1234 And script.php has the following script: $key=array_keys($_GET); echo $key[0]; The output will be: 1234 (I'm trying to do away with the ugly ?r=1234 and if this works, it will be perfect.) My question is, is this officially correct or it's ...

How can I send an auto email from MySQL records?

I am using a MySQL database and PHP. My MySQL database contains the following records: Name Address Data email Date Joy Fortblair 10 [email protected] 1/22/2009 Bob Atlanta 15 [email protected] 2/22/2009 My intention is to send the email using PHP with the following conditions: The data is 1 d...

Is PHP thread-safe

Is PHP (as of 5.2) thread-safe on Linux/UNIX? Would it be possible to use it with Apache Worker-MPM or Event-MPM? The facts I gathered so far are inconclusive: default binaries included in most distributions have ZTS disabled, so I aware, that I'd have to recompile them. in theory Zend Engine (core PHP) with ZTS enabled is thread...

Cache-Control Header Modified By PHP Session?

I'm outputting an image to the browser using a Zend_Controller_Response object. It is my intention to apply caching to the image, however something is causing the Cache-Control header to be overwritten. My code is as follows: $this->getResponse() ->setHeader('Last-Modified', $modifiedTime, true) ->setHeader('ETag', md5($modifi...

Getting ORA Oracle error code using PHP function oci_connect?

The PHP function oci_connect (which connects to an Oracle database) just returns false if it fails, which at the moment I handle like this: $connection = oci_connect($username, $password, $database); if (!$connection){ return $result = "Trouble connecting to the Oracle Database"; } But really I'd like to have the actual ORA error cod...

Zend: Is it possible to send view variables after a redirect?

How could I send additional view parameters after I have done a redirect (e.g. $this->_redirect->gotoSimple();)? For example, let's say I have an Edit action which will redirect the user to an Error action handler and I would like to be able to send custom, detailed error messages to its view. To illustrate it clearer, the flow would be...

Class Diagram for classless PHP application

Hello all, I have PHP application that is completely procedural (No PHP Classes). In my case, is there any formal diagrams I can draw to show how my web application that is equivalent to a UML class diagram for OOP based applications. Thanks all ...

php mysql character set: storing html of international content

i'm completely confused by what i've read about character sets. I'm developing an interface to store french text formatted in html inside a mysql database. What i understood was that the safe way to have all french special characters displayed properly would be to store them as utf8. so i've created a mysql database with utf8 specified ...

Safe JavasScript that calls PHP script that calls external web service

I have a PHP page that needs to make a call to a external web service. This Web service call takes a bunch of sensitive data from a html form on the PHP page, e.g. SSN, and returns info related to that person. The problem is that the web service call should be made as soon as the customer fills in the SSN field and the field loses focus...

Drupal CCK: how to output a node teaser with its fields?

Hi, In a module of mine, I'd like to output the node teaser. The node has CCK fields, and I'd like them to be displayed accordingly to the visibility settings you can choose in the content types / field settings administration area. But when I do: $html = theme('node', $n); the resulting teaser won't contain the CCK fields, only tit...

Fulltext search in MySQL and PHP doesn't work

Hello, I'm currently trying to perform a search over 2 fields in my MySQL table (text type) using PHP. SELECT * FROM content_items WHERE MATCH (content,name) AGAINST ('".urldecode($_REQUEST['term'])."' IN BOOLEAN MODE) I'm always getting zero results, no matter what I search for (even tried to make the query static and it still didn...

Returning JSON from PHP to JavaScript?

I have a PHP script that's being called through jQuery AJAX. I want the PHP script to return the data in JSON format to the javascript. Here's the pseudo code in the PHP script: $json = "{"; foreach($result as $addr) { foreach($addr as $line) { $json .= $line . "\n"; } $json .= "\n\n"; } $json .= "}"; Basically, I...

Specify page/line when throwing die() ?

I am using PHP 4, the only way I know of to cause an error and stop everything is calling die(). But in case I run into the error later and don't remember where its coming from I would like to specify the page and line number that the die() occurred on (like other php errors do). Is there a way to do this? Thanks! ...

PHP: Parse a string to perform replacements

I have a group of text based rules that are structured like this: Rule 1: Do [XXX] when [PN] greater than [N] Rule 2: Get [PRD ..] and add [X.XX] To go with this is an array of data that translates each grouped code into a CSS class ID (for jQuery). I also have an array of translations from [code] to ID stored in a simple structured...