php

Why only ASP.NET have asynchronous programming model?

I works with ASP.NET. IMHO, the asynchronous programming support in ASP.NET is beautiful. That is, we can have BeginXXXX/EndXXXX pair method to improve scalability for resource intensive task. For example, one operation needs to get huge data from database and render it on response web page. If we have this operation synchronous. The t...

how to get random image from directory using php

i have one directory called imaages/tips Now in that i have many images which can chnage I want that the php script should read the directory , finds the images and out of those images found pick random image very time Any idea ...

PHP stylesheet print switcher problem revisited?

Okay I have this style sheet switcher which will only works if I leave out the media="print" from the style sheet link. I was wondering how can I fix this problem without leaving out the media="print" attribute. Here is the PHP code. <!-- Print Script --> <?php if (isset($_GET['css']) && $_GET['css'] == 'print') { ?> <meta name="robot...

Handling successive Ajax requests - JQUERY

Hi guys, I have a search textbox where upon keppress an ajax call is made to return search results for the inputted text. The thing is that this results in an Ajax call being made for like every single keypress - so if I wish to type in lets say airport I get 7 ajax requests each searching for a, ai, air, airp, airpo, airpor, airport re...

Advice needed from PHP/Cake PHP expert

I'm very new to programming (besides SQL and databases), but I ultimately want to master Cake PHP for web development. Now, given how new I am, I'm rather lost as to how I get started. Down the road, I want to use MVC framework so that I help myself be disciplined in the way I build. However, I know basic knowledge of PHP and OOP PH...

Loop: Need help with loop and efficiency

Currently, I need help with my loop. In each div, I want it to show two sets of FirstName and LastName instead of just one set, but I don't know how can I do that because of the loop. Also, the point of setting different font sizes is to create a visual look which is a funnel like shape. My question is, how can I add another set of name ...

CakePHP: Return the SQL for Model::find() rather than running it

Is there a way to get the SQL which would be run for a particular find() query, rather than actually running it? For example: echo $this->Users->find_sql('all'); // "SELECT User.id, User.username FROM users User WHERE 1=1" My own situation would be a little more complicated than this, but I hope it illustrates the desired output. ...

Sorting XML data in PHP4

Hi there I have the following XML code: <?xml version="1.0" encoding="UTF-8"?> <connector_ret> <function name="search"> <row id="1"> <col id="1">AAA</col> <col id="2">243168</col> <col id="3">090828-000300</col> <col id="4">Subject</col> </row> <row id="2"> <col id="1">BBB</...

How to use Sessions in Symfony?

like in classic PHP we use the magic variables to start,create session, so how to do that in Symfony. ...

Easiest way to remove all whitespace from a code file?

So I'm participating in one of the Code Golf competitions where the smaller your file size is, the better. Rather than manually removing all whitespace etc, I'm looking for a program or website which will take a file, remove all whitespace (including new lines) and return a compact version of the file. any ideas? ...

PHP - Getting limited chunks of a large array from MySQL table

Let's say you've got a table like this: ID Cat1 Cat2 1 a red 2 b red 3 c blue 4 d blue 5 e blue 6 f green etc etc etc The goal is to display the ID and Cat1 (unique pairs), split into groups according to Cat2. The easy way out is to run a separate MySQL query for each Cat2, but with a lot...

submitting multiple items to paypal cart at once with php

I have some items for sale that have 2 and 3 levels of customization. Once set the user adds them to my onsite cart. Problem is, how can i send each item to paypal on checkout? The only code ive found for dynamic buttons supports only a single item. <form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal"> <inp...

Angle brackets in php

I want to store angle brackets in a string in PHP because i want to eventually use mail() to send an HTML email out. The following is the code that doesn't seem to work. while(...) { $msg .= "<img src=\"http://.../images/".$media['Path']."\"&gt;&lt;br&gt;"; echo "message: ".$msg."<br>"; } What I want is for $msg to contain a bu...

Flex + PHP: Flash Builder 4 vs. Eclipse

I'm getting started with Flex and initially installed the Adobe environment (Flex Builder 3) and later found out that they're starting to call it Flash Builder 4. Anyway since I'm very new to this technology and I have to leave Flex Builder 3 anyway, I'm trying to find out if there are any advantages to developing with Adobe's Flash Bu...

Gears and Mysql sync

Hi, I am making an offline website that needs to sync every night with a server. Our employees work outside and sometimes underground and need to access the site for its database. But once home they must send us their findings. The first time they connect, I check with google gears if they have the sqlite database and if not I run a sc...

Will this regular expression ^[^\s]+$ prevent SQL injection? if No how to get around the restriction?

used to check user input like username not a login account. ...

PHP gdLib 8-Bit PNG with alpha

Hi, how is it possible to save my image, created with gd, as an png-8? it saves as gif with transparent channel well - but I want to use png-8. Best Regards, Beerweasle ...

accessing private variable from member function in PHP

I have derived a class from Exception, basically like so: class MyException extends Exception { private $_type; public function type() { return $this->_type; //line 74 } public function __toString() { include "sometemplate.php"; return ""; } } Then, I derived from MyException like so: cl...

How do I change "date field" format of a "view" in the form of a page in Drupal?

I'm trying to show a list of dates of Nodes using view. The list should be something like, 19 September 2009 20 September 2009 Right now it can only show like Thu, 2009-11-12 (All day) Mon, 2009-11-09 (All day) ...

How to get the length of longest string in an array

Say I have this array: $array[] = 'foo'; $array[] = 'apple'; $array[] = '1234567890; I want to get the length of the longest string in this array. In this case the longest string is 1234567890 and its length is 10. Is this possible without looping through the array and checking each element? ...