php5

PHP object serialization and Sessions

Hi there, I have a quick question, first one too! How is it possible to serialize sub-objects to $_SESSION? Here. <?php // this is "arraytest.php" class arraytest{ private $array1 = array(); public function __construct(){ $this->array1[] = 'poodle'; } public function getarray(){ return $this->array1; ...

Variable into Header Location

How can i include a variable and make it part the string. header("Location: http://www." . "$_SESSION['domainname']"); The above code doesn't work. ...

php array to xml, using same array key names

We are using pear's xml serializer to turn our request arrays into XML to submit to other servers for an XML response. The problem is, for one of the attributes we will need to submit an XML similar to this <totalRooms> <Room> ... </Room> <Room> ... </Room> </totalRooms> How do we compile this in PHP arrays so the Ser...

PHP: How can I get rid of commas inside double quotes in a multiple column row?

I need a PHP solution to get rid of commas inside double quotes. I can't seem to figure out a solution using preg_replace. I'm inserting data into a database from a text file that is coma delimited. Certain columns from the text file contain multiple words that are surrounded in double quotes. Theses double quotes have comas inside, so...

Problems with imagesetpixel and displaying the image with php5 and gd 2.0 (or higher, apparently)

I'm trying, for reasons best known to my unconscious mind, to generate a snow-crash-like picture. Using PHP5 and GD v2.0 (or higher), I'm using the following php/html: <?php $x = $y = 100; $gd = imagecreatetruecolor($x,$y); $w = imagecolorallocate($gd, 255, 255, 255); $b = imagecolorallocate($gd, 0, 0, 0); ...

SOAP on Subdomains

I am working with an application that is used by multiple clients. Each client has its own database, but multiple clients use the same php codebase. In essence, we use named virtual servers on apache to point the url to the right codebase on the server. When the browser hits the php code, the code checks a master database to see which...

Updating PHP.ini on a GoDaddy Hosted site.

I am pretty new to PHP programming so I apologize if I am missing the obvious. I have a site hosted at GoDaddy (Windows, PHP5, MySQL 5). I read this article: GoDaddy FAQ and created a php5.ini file in the root folder but when I try to connect to the database, I get the following error: Fatal error: Call to undefined function mysq...

PHP Send mail error

Please help me I am New in PHP and since last 5 Hours i am try to semd mail and now really tired. Thanks. Here is my code. I am using Gmail account. include("class.phpmailer.php"); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $bod...

Looking for a clean, efficient way to match a set of data against known patterns.

Using php5.2 and MySQL 4.1.22 I've come across something that, at first, appeared simple but has since evaded me in regards to a simple, clean solution. We have pre-defined "packages" of product. Package 1 may have products A, B and C in it. Package 2 may have A, C, D and G in it, etc. The packages range in size from 3 to 5 products. ...

Filter array - odd even

How can a filter out the array entries with an odd or even index number? Array ( [0] => string1 [1] => string2 [2] => string3 [3] => string4 ) Like, i want it remove the [0] and [2] entries from the array. Or say i have 0,1,2,3,4,5,6,7,8,9 - i would need to remove 0,2,4,6,8. ...

PHP: Does sleep time count for execution time limit?

Hello! I have two questions concerning the sleep() function in PHP: 1) Does the sleep time affect the maximum execution time limit of my PHP scripts? Sometimes, PHP shows the message "maximum execution time of 30 seconds exceeded". Will this message appear if I use sleep(31)? 2) Are there any risks when using the sleep() function? Does ...

Passing an Array as Arguments, not an Array, in PHP

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to do it. I recall the manner of passing by reference, how to "glob" incoming parameters ... but not how to de-list the array into a list of a...

Possible PDOException Errors (MySQL 5)?

So I'm setting up an installer for my web app, and have input fields for database credentials. Part of my validation process includes testing the database connection (using PHP's PDO library). If the connection fails, I want to be able to differentiate between a bad password, bad address, nonexistent database name, etc. so I can referenc...

How do I set partial transparancy in GD with PHP?

I am attempting to make a dynamic image with PHP, and I can't find out how to set partial transparency. It is very easy to make things either solid or fully transparent, but I have been unable to do this. ...

Migrating php4/mysql4 to php5/mysql5: expected php issues?

I have a legacy web application php4/mysql4 (MyISAM, db contains some cms, some user data, some calendar application). Now I am going to migrate to a new server with php5/mysql5. What are the typical php issues in such a migration scenary (php, sql queries, anything)? I've heard that the function parameter passing changed, call-by-refe...

What is the correct PHP configuration to connect to MS SQL 2000/2005?

I have a number of servers running PHP 5.2.6 (non-thread-safe build) on Windows 2003/IIS6 utilising FastCGI. I'm having some issues connecting to MS SQL 2000/2005 (MySQL connectivity is working fine, ASP/ASP.NET scripts can connect to MS SQL successfully as well). One solution suggests copying the SQL Client Tools ntwdblib.dll file to ...

How to delete a PHP session?

It's possible I'm not properly deleting PHP sessions when the user signs out. I've noticed that if I sign out and sign back in without closing the browser, the session ID doesn't change but if I sign out, close the browser window, open a new one and sign in, the session ID will be different. Do I need to be doing something different or i...

Will PHPUnit and XDebug work together?

I've been working on writing unit tests for my PHP code. PHPUnit is what I'm using for this. I have some classes that work great until... I throw XDebug into the mix. At that point, PHPUnit doesn't crash or anything, but setExpectedException never triggers. In fact, the code never goes beyond that point. Anyone run across this and ...

Unit Testing - Is this the 'right' way or the 'wrong' way?

If you were testing a count function like the one below, is it considered to be 'right' or 'wrong' to test multiple things for the function in one function vs having a test function for each of the tests? function testGetKeywordCount() { $tester = $this->getDatabaseTester($this->CompleteDataFile); $tester->onSet...

Optimizing a non-tail-recursive function.

I have this function whose essential operations are outlined as follows: function render($index) { foreach($things[$index] as $key => $data) { echo '<div>'; /* irrelevant operations */ if(isset($data['id'])) { echo '<div class="wrap">'; render($things[$data['id']]); echo '<...