php5

PHP fsockopen to curl conversion

i have this piece of code: <?php $host = "registration.mypengo.com"; $request = "/webregistration.aspx?taskaction=serviceresponse&partner=157&subid=" . $subid . "&msisdn=" . $msisdn . "&type=TEXT&data=" . $data . "&serviceid=" . $service_id; $fp = fsockopen($host, 80, $errno, $errstr, 3.0); if($fp) { fwrite($fp, "GET $request HTT...

How to iterate over an array of objects without foreach and ArrayAccess

Hi, I'm having to develop a site on PHP 5.1.6 and I've just come across a bug in my site which isn't happening on 5.2+. When using foreach() to iterate over an object, I get the following error: "Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference..." Does anyone know how to convert the fo...

PHP: Recursive array function

Hi everybody, I want to create a function that returns the full path from a set node, back to the root value. I tried to make a recursive function, but ran out of luck totally. What would be an appropriate way to do this? I assume that a recursive function is the only way? Here's the array: Array ( [0] => Array ( ...

how to get rid of empty elements

I have an array thats generated dynamically and it has some empty elements. How do I get rid of empty elements from an array? array 0 => string '' (length=0) 1 => string 'x%6wm' (length=5) 2 => string 'x%6wmvf' (length=7) 3 => string 'x%645' (length=5) 4 => string '' (length=0) And I want it to become like array 0 => str...

What is the best way to include a php file as a template?

I have simple template that's html mostly and then pulls some stuff out of SQL via PHP and I want to include this template in three different spots of another php file. What is the best way to do this? Can I include it and then print the contents? Example of template: Price: <?php echo $price ?> and, for example, I have another php...

Show a different template after two days in php with date()

I have this code to capture a date and time: date('F j, Y, g:i a T') and save is as $datetime: and I have this code to include a template: function template_contents($file, $model) { if (!is_file($file)) { throw new Exception("Template not found"); } ob_start(); include $file; $contents2 = ob_get_conten...

Gearman: Run both client and worker on same machine?

Hi everybody, I just manage to install gearman on my local Ubuntu test environment. I wonder if I could in any way run both the worker and the client at the same computer, while in development stage? Thanks a lot! ...

How to create PHP method linking?

I've seen other objects that do this: $obj->method1()->method2(); How do I do that? Is each function just modifying the pointer of an object or returning a pointer? I don't know the proper term for this style -- if anyone could help me with that, it would be great. ...

How server manage different user's requests at a time?

can you tell me how server handles different http request at a time. If 10 users logged in a site and send request for a page at the same time what will happen? ...

How do you sort php and sql arrays?

How can I sort this array by city or by id in descending order? if ($num > 0 ) { $i=0; while ($i < $num) { $city = mysql_result($result,$i,"city"); $state = mysql_result($result,$i,"state"); $id = mysql_result($result,$i,"id"); echo "$city"; echo "$state"; ++$i; } } else { echo "No results."; } ?> ...

Only show certain items in a mysql database using php and time()

Is there a way to only show the items that are older than a certain date in a php mysql array? I'm using this query method and sorting by lastpost_cl: $query="SELECT * FROM properties ORDER BY lastpost_cl"; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); and I was thinking the way of checking the time wou...

Is Zend Framework 1.10.x compatible with PHP 5.3?

I'm currently developing in (learning) ZF1.10. I also just set up a new development server using Ubuntu 10.04 which came with php 5.3 I know that ZF will start using php 5.3 functionality as of ZF2, but will ZF1.10 work fully and normally running on a php 5.3 machine or should I downgrade my php? For example, my own legacy code has prob...

PHP 5.3, using old authentication?

Hi. We're setting up a new webserver with PHP5.3 and are getting the "Error: could not connect: mysqlnd cannot connect to MySQL 4.1+ using old authentication ?" error message. After some google'ing I've found that we should set old passwords = 0 in my.cnf and reset the password(s). But we still have webservers running php 4.x & 5.2 that ...

php joomla session lifetime settings

I have searched through the google and also joomla forums but didn't got what exactly I was looking for. My main purpose is to set the joomla session live for ever. Many forums says its not good to keep a higher value (security issues) but I don't want to consider that right now. My question is : What if I set the session lifetime va...

PHP Interpreter/Compiler

I am trying to understand how the php compiler/interpretor works. I tried to download the php source code and tried to understand how it works. I was not able to find proper documentation. WOuld be great if someone could throw light on th modules that make the php compiler and also how the apache server uses the php compiler.. Thanks ...

How PHP scripts compile?

Can you tell me what are the process in a php file compilation. ...

Gaining application/module context from a symfony task

I have written a reporting suite, and I have a specific report that builds a CSV file. Serving this file via a browser on demand isn't an issue, but I need to be able to build this CSV file nightly, and email round a link to be able to download it. Essentially, I need to be able to replace a specific action with a symfony task, run via ...

Ideal way of dealing with Solr results in PHP?

Firslty, I'm aware of some similar questions along the lines of this one, but I think this situation is different enough to warrant its own question. I'm running a Solr index, through a jetty install on a LAMP server. I currently use the simplexml_load_file function to bring in the search results and then parse them trough a couple of f...

what does & do in php

I have this code $myNewClass->cars =& Orders_Car::GetRecords($myNewClass->searchString); ^ what is & doing there. thanks ...

on updating any field from dropdown list into MYSQL with white space, data gets truncated

Hello is there any one who can help me. i'm working on PHP and MySQL. inserting data and even retriving them are all fine. when i insert any data from dropdown list works fine and i can see data correctly inserted. if i dont change any data in the dropdown list and simply click on update button then those data having white space or / get...