php

Passing arrays using json?

Hello I have this php code $ids = array(1,2,3); $names = array("cat","elephant","cow"); $originalSettings = array ('ids'=>$ids,'names'=>$names); $jsonSettings = json_encode($originalSettings); echo $jsonSettings; and this is the jQuery code $.post("ajax.php", {}, function(data){ data.ids.each(function(i) { alert(dat...

Improve speed by memory+eval or use regular file

I'm trying to improve the speed of our server but I would like to have your view of that before modifying everything. I have a high read rate on my file system. Right now we are using regular PHP file. I wonder if I can cache these file in Memcache and later do an eval on the code if it will be faster than letting these file get interpr...

what characterset to use when i create my database

So I am doing a lot of php tutorials and I always wonder when creating my different DBs... What charset should I be using? Depending on what DB interface I use it seems to default to different options. So what is the most common one I should use for basic programing... Or can someone point me to a good guide to charsets in MySql ...

Batch processing in array using PHP

I got thousands of data inside the array that was parsed from xml.. My concern is the processing time of my script, Does it affect the processing time of my script since I have a hundred thousand records to be inserted in the database? I there a way that I process the insertion of the data to the database in batch? ...

Creating links in Flex

private function google(event:ResultEvent):void { Alert.show(event.result.loginsuccess.keyword[0]); subtitle.visible=true; Results.visible=true; Occur.visible=true; query.visible=true; subtitle.text = "Search results for " + event.result.loginsuccess.keyword[0]; ...

Creating link in dataGrid

<mx:DataGrid visible="false" id="dgPosts" width="365" click="" dataProvider="{sendReq.lastResult.loginsuccess.name}" x="140.5" y="169"> <mx:columns> <mx:DataGridColumn headerText="name" dataField="name"/> </mx:columns> </mx:DataGrid> When i click on a particular dataItem, the corresponding w...

forcing a file to download

Duplicate: http://stackoverflow.com/questions/531292/any-way-to-force-download-a-remote-file I have a php page with information, and links to files, such as pdf files. The file types can be anything, as they can be uploaded by a user. I would like to know how to force a download for any type of file, without forcing a download of l...

Creating Wordpress-style extracts

I'm working on a site that pulls various public RSS feeds down. I want to show a HTMLless, short description of the feed entry. Some of the feeds come with a nice excerpt but lots don't so I'm left making my own from the full-content. So what is the best/quickest/easiest way to take a block of text and slice it down to just the first ...

How to use the jQuery Cycle Plugin with WordPress?

I have tried everything that I can think of. It shouldn't be this hard. Can some one please explain to me the process of using jQuery with WordPress (specifically jQuery Cycle Plugin)? in header.php I have: <?php wp_enqueue_script('jquery.cycle.all.min', '/wp-content/themes/andrewhavens/jquery.cycle.all.min.js', array('jquery')); ...

Output as array

$result = mysql_query(" SELECT p.page_url AS url, COUNT(*) AS occurrences FROM page p, word w, occurrence o WHERE p.page_id = o.page_id AND w.word_id = o.word_id AND w.word_wor...

PHP/Cronjob saved search scalability

Our real estate website sends email notifications when properties come on the market matching users saved search criteria. I have a PHP script that runs on the cronjob to process the searches. The system now has over 40,000 users. I ran into an issue where I exhausted the PHP memory size. As the system grows I can continue to increas...

Is it possible to exit gracefully in a constructor?

Is it possible to exit gracefully out of a constructor in php? Something to the effect of class Foo { function __construct() { $active = false; if(!$active) { return false; } } } I'm trying to accomplish this because I want to check to see if any of the methods in the class should run based on a configuration ...

mysql_query doesn't work in IIS - alternative?

I'm using PHP in a Windows/IIS environment and found this db related code not to work: $result = mysql_query("SELECT * FROM users WHERE id=12); So is there an alternative to mysql_query? ...

What is the difference between redirect and forward in Symfony ?

I want to know the difference between : $this->forward("module", "action"); And $this->redirect("module/action"); My first guess is that one implies a new request while the other one not, but I'm not sure. ...

Why am I getting "validator failed" one a save with Doctrine on Symfony 1.2 ?

Let's say that I have YAML scheme looking like that : Note: options: type: MyISAM collate: utf8_unicode_ci charset: utf8 actAs: { Timestampable: ~ } columns: content: { type: string, notnull: true} order_id: int(5) user_id : int relations: User: foreignAlias: Notes local: user_id for...

Am I using the Symfony flash variables the wrong way ?

In an action, I set some feedback for the user : $this->getUser()->setFlash('message', array( "type" => "notice", "content" => "Well done buddy, you did it." )); $this->redirect('home/index'); In the view, I just use the following code : <?php if ($sf_user->hasFlash('message')): $message = $sf_user->getFlash('mes...

Check If Username Exists

Whats the best way to check if a username exists in a MySQL table? ...

How can I get around the lack of a finally block in PHP?

PHP has no finally block - i.e., whereas in most sensible languages, you can do: try { //do something } catch(Exception ex) { //handle an error } finally { //clean up after yourself } PHP has no notion of a finally block. Anyone have experience of solutions to this rather irritating hole in the language? ...

Upload Entire Directory via PHP FTP

Hey, I'm trying to write a script that will upload the entire contents of a directory stored on my server to other servers via ftp. I've been reading through the documentation on www.php.net, but can't seem to find a way to upload more then one file at a time. Is there a way to do this, or is there a script that will index that direct...

Any netbeans features that will make my day?

Hi all, I've recently gotten quite fond of netbeans for my php work because of the XDebug integration. It has made me all but forget about textmate (which imho still beats netbeans for the little things) What do you think is the one awesome netbeans feature I should know about, and more importantly why and how do I use it? I'm aski...