php

Parallel mysql queries in php?

I am sharding my data into multiple mysql databases, but sometimes I will need to gather information from multiple shards. How can I query multiple mysql databases in parallel in php? I've seen some examples of asynchronous curl requests and shell_exec, but is there a more direct way? ...

Do MySQL prepared queries provide a performance benefit for once-per-session queries?

According to the documentation, a prepared query provides a significant performance benefit if you're running a query multiple times because the overhead of the MySQL server parsing the query only happens once. I'm wondering what exactly they mean by "multiple times" there. I.e., say you have a web page that runs a query one time. Now s...

scripts embedded in images

I run a small browser MMO, and I have a problem where a couple users are embedding scripts into their profile images, and using them to make attacks against said users, and my game in general. Is there a way to protect against this, or do I need to start blocking people from being able to use their own custom images? If it helps any, i...

PHP memcache design patterns

Hi We use memcache basically as an after thought to just cache query results. Invalidation is a nightmare due to the way it was implemented. We since learned some techniques with memcache thru reading the mailing list, for example the trick to allow group invalidation of a bunch of keys. For those who know it, skip the next paragraph...

PHP 3 to PHP 5 Upgrade... Variables in 3 didn't have $ in front... is there a setting for back compat?

OK, this is an odd request, and it might not even be fully true... but I'm upgrading someone's system ... and they are using OSCommerce (from a long time ago). It appears their variables are referrenced without a dollar sign in front of them (which is new to me). I haven't done PHP in about 7 years, and I've always used dollar signs. I...

Can you enable variable highlighting with Eclipse PDT?

I'm using version 3.3.2, I know that regular Eclipse for Java does variable highlighting. Notepad++ does it regardless of what language you're using (if you select any text, it highlights similar text) I know it's not critically important, and a back/forward incremental search is an adequate workaround, but it would be nice to have. Up...

What language is a good choice after PHP for a developer wanting to try something new?

I've been using PHP ever since I got a job in web development (late last year). I currently have a desire to learn something new. I was considering Python. Has anyone else been in this state of mind, and what were their choices? Did they end up learning a new language, or did they rethink their PHP approach for a fresh breath of PHPnes...

PHPSpec - fail to run, anyone using it for php development?

Searched stackoverflow for this and found no answer Coming from Ruby On Rails and Rspec, I need a tool like rspec (easier transition). Installed it through PEAR and tried to run it but it's not working (yet) Just wanna ask around if anyone's using it have the same problem, since it's not running at all tried running it with an example...

Is there an equivalent for var_dump (PHP) in Javascript?

We need to see what methods/fields an object has in Javascript. ...

Force re-cache of WSDL in php.

I know how to disable WSDL-cache in PHP, but what about force a re-caching of the WSDL? This is what i tried: I run my code with caching set to disabled, and the new methods showed up as espected. Then I activated caching, but of some reason my old non-working wsdl showed up again. So: how can I force my new WSDL to overwrite my old ca...

variable not being passed?

Hello, I have this code while($row = mysql_fetch_row($result)) { echo '<tr>'; $pk = $row[0]['ARTICLE_NO']; foreach($row as $key => $value) { echo '<td><a href="#" onclick="GetAuctionData(\''.$pk.'\')">' . $value . '</a></td>'; } which gets pk. pk is then passed on to the axjax part with this: function GetAuctionData(pk) { ..... var...

Webservice Authentication

I'm working on a webservice + AJAX interface, and I'm worried about authentication. This moment I'm passing username and password to the webservice as arguments, but I fear that this approach is highly insecure. I was told that ssl could solve my problem, but I want more alternatives. My webservice is written in php and my interface is ...

Putting a value on the load of a windows system

I've written an image processing script in php which is run as a cron scheduled task (in OSX). To avoid overloading the system, the script checks the system load (using 'uptime') and only runs when load is below a predefined threshold. I've now ported this over to Windows (2003 Server) and am looking for a similar command line function ...

PHP/MSSQL Report Writing

What is a good method of writing reports using PHP and MSSQL? Is there a third party vendor that supports MSSQL? ...

Subversion... practical with a PHP framework app or not?

I am developing a website using CodeIgniter and PHP. Some of my friends suggest I start using Subversion to take care of my organization. Could someone give me a basic explanation of what SVN is without the jargon and also if it is practical for a framework where 5 files are needed to run a single page? ...

How can I cut off a RSS feed description after 2 sentences using preg_split?

I want to take a description of a RSS feed located in $the_content and cut it off after 2 full sentences (or 200 words and then the next full sentence) using preg_split. I tried a couple times, but I'm way off. I know what I want to do, but I can't seem to even start on something to make this work. Thanks! ...

Zero-pad digits in string

Hi I need to cast single figures (1 to 9) to (01 to 09). I can think of a way but its big and ugly and cumbersome. I'm sure there must be some concise way. Any Suggestions ...

Converting pdf files to txt files with php

There's this program, pdftotext, that can convert a pdf file to a text file. To use it directly on the linux console: pdftotext file.pdf and it will generate a file.txt on the same directory as the pdf file. I was looking for a way to do it from inside a php program, and after some googling i ended with two commands that should work f...

Which is faster: in_array() or a bunch of expressions in PHP?

Is it faster to do the following: if ($var != 'test1' && $var != 'test2' && $var != 'test3' && $var != 'test4') { ... } Or: if (!in_array($var, array('test1', 'test2', 'test3', 'test4') { ... } Is there a number of values at which point it's faster to do one or the other? (In this case, the array used in the second option doesn'...

Is there a way to execute php code in a sandbox from within php

I want to execute a php-script from php that will use different constants and different versions of classes that are already defined. Is there a sandbox php_module where i could just: sandbox('script.php'); // run in a new php environment instead of include('script.php'); // run in the same environment Or is proc_open() the only ...