I'm looking for general a strategy/advice on how to handle invalid UTF-8 input from users.
Even though my webapp uses UTF-8, somehow some users enter invalid characters. This causes errors in PHP's json_encode() and overall seems like a bad idea to have around.
W3C I18N FAQ: Multilingual Forms says "If non-UTF-8 data is received, an e...
Hi There! There is a problem of automatically retrieving field names from a MySQL table. If possible could the name be placed in this format along with the dynamically created text box? :
The codes that I have created so far are located below:
<?php
include "db_connect.php";
$name = mysql_query("SELECT * from users");
$property = m...
Hi all,
I've following abstract class and have a question about how to write a unit test for this. Is this in fact needed? As this class doesn't have any concrete methods.
<?php
abstract class PickupPoint_Abstract {
public function __construct($client) {}
public function getPickupPoints($countryCode, $postalCode, $city) {}
...
I'm trying to publish messages to RabbitMQ from a php (5.2.x) script on my windows X64 dev machine.
The problem is that I didn't find any dll extension for php. My collegue is actually trying to build it (cf. How do you compile a PHP extension on windows with cygwin/mingw?), but without success :(.
Does anyone know where I can find a v...
Class test{
function test1()
{
echo 'inside test1';
}
function test2()
{
echo 'test2';
}
function test3()
{
echo 'test3';
}
}
$obj = new test;
$obj->test2();//prints test2
$obj->test3();//prints test3
Now my question is,
How can i call another function before any called function execution?
In above case, how can i auto call 'test1'...
I'd really like to get deeper into my php scripts and use things like breakpoints, as I'm doing with JS with firebug.
I've recently had no end of "fun and games" with magento and ZF, and I'm certain that some more sophisticated debugging techniques would have saved a lot of time.... ;)
However, there doesn't appear to be much in the w...
I am in the process of making a page fetch script & I was using curl for it. I used the function:
get_data($url);
but I always get the error:
Fatal error: Call to undefined function get_data() in D:\wamp\www\grab\grab.php on line 16
I am using WAMP server and I have enabled curl extentions in all the ini files, I have checked the ex...
Hi,
I am sending data using HTTP POST to my server. But in the server, I am not receiving the data. And somehow I don't have any way to check the data (or debug script) on client side. But on client side I am getting HTTP 200, means data is sent. Also I can see the connection and data sending was successful. However log in the server doe...
Hi all,
I've got following factory class which has a dependency $client. I moved the dependency to the factory class as it first occurred in Service_Service1 class so I could test the service class. But how can I test the factory class?
class Factory implements Service
{
public static function factory($service)
{
$conf...
We're migrating from PHP 4 to 5 (FINALLY!)
I need a php script to connect to an external server over SSL-FTP. Long story short, this works on PHP 4, but not 5.
<?
$user = "USER";
$pass = "PASS";
$conn_id = ftp_ssl_connect("WEBADDRESS.com",21) or die ("could not connect");
$login_result = ftp_login($conn_id,$user,$pass);
?>
On 5 it r...
I know there are Comet server technologies that do this but I want to write something simple and home-grown.
When a record is inserted into a MySQL table, I want it to somehow communicate this data to a series of long-polled Apache connections using PHP (or whatever). So multiple people are "listening" through their browser and the sec...
For my project I wrote a small config class that loads its data from a .ini file. It overwrites the magic __get() method in order to provide simplified access to the (read only) config values.
Example config.ini.php:
;<?php exit; ?>
[General]
auth = 1
user = "halfdan"
[Database]
host = "127.0.0.1"
My config class (singleton pattern...
hi there!
i'm working on some piece of code that should get the contents of a very specific html-tag of an html-document given.
$html = "<html>..........truncated.........<div>blablabla<br />xy</div>.....";
$dom = new DomDocument();
$dom->loadHTML($html);
$divs = $dom->getElementsByTagName('div');
echo $divs->item(0)->nodeValue.'<br>...
I'm trying to reference a private variable of an object from within a closure. The code below would seem to work, but it complains Fatal error: Cannot access self:: when no class scope is active in test.php on line 12 and Fatal error: Using $this when not in object context in test.php on line 20.
Any ideas how to accomplish the same res...
Hi,
I am using PHP5, and heard of a new featured in object-oriented approach, called method chaining.
Does any one know what it is?
I want to know how to implement method chaining using PHP5 with object-oriented approach.
Thanks
...
I'm using the AutoSuggest jQuery Plugin:
http://code.drewwilson.com/entry/autosuggest-jquery-plugin
So basically what it does is create a hidden input field containing comma separated values; the IDs of the Names in the AutoSuggest field. Using Firebug, I confirmed that the hidden field was created and the IDs were inserted in the 'valu...
After downloading, building and installing a new version of PHP5 on a SuSe Linux distribution, I can not get Apache to recognize it.
Why isn't mod_php5.so being overwritten? Or do newer versions of PHP use a different so?
...
I have a PHP5 site running on IIS7 and I just wanted to add basic authentication on a subfolder called admin.
I enabled both anonymous authentication and basic authentication and I just want to turn off anonymous authentication on the subfolder in order to force the basic authentication?
Any suggestions?
I tried adding a web.config in...
Hello,
I have thsi result if I vardump an array.
`object(stdClass)#284 (39) { ["nid"]=> string(3) "516" ["type"]=> string(10) "classified" ["language"]=> string(2) "de" ["uid"]=> string(4) "5074" ["status"]=> string(1) "1" ["created"]=> string(10) "1284678918" ["changed"]=> string(10) "1284678918" ["comment"]=> string(1) "0" ["...
In PHP what is the most efficient way to parse this string into an associative array?
%STCITY^LASTNAME$FIRSTNAME$MIDDLENAME^ADDRESS1$ADDRESS2^?;UNIQUEID=YYMMDDYYMMDD=?
...