php

jQuery issues when using ajax and .attr('class', 'new_class')

I am using Zend Framework, and to illustrate what is working I added the saveAction() to this post and it works flawlessly. It will animate and change the class as I want. The function upload instead only change the text and ignore the javascript. I can do alerts that works, however jquery is not possible. I get error saying that $ is un...

PHP emitting 500 on errors - where is this documented?

In this question the OP mentions PHP throwing a 500 error automatically when error_reporting is off, and XDebug changing that behaviour. That got me curious, as I've never heard of PHP automatically emitting 500s before. According to various quotes and answers on SO and elsewhere, it seems to indeed be PHP's default behaviour to throw a...

Fetching latest blog post on wordpress using php?

Hey, I have used this php to fetch my blog's latest post: function read_rss($display=0,$url='') { $doc = new DOMDocument(); $doc->load($url); $itemArr = array(); foreach ($doc->getElementsByTagName('item') as $node) { if ($display == 0) { break; } $itemRSS = array ( 'tit...

preg_replace array: mask regex characters problem

I want to replace word groups by links. The word groups are defined in a multi-dimensional array. There will be thousands of terms to be replaced, so an unindexed, light-weight and multi-dimensional array is needed. Nothing should be replaced when the term is followed by brackets or inside square brackets. Problem: The regex itself w...

Call function of just created object

How to call function of just created object without temporary variable? Code (new \Foo())->woof(); is not valid in php. What is right? ...

dojo combobox and radio button

I would like some help on how to do this task (PHP and Dojo) Currently I have 2 dojo radio buttion and a dojo combobox. When the user click on a radio button I would like to do the followng: 1: Execute a JS/dojo function call a php method that return a json object populate the combobox with the new context and select ...

What is the purpose of the intial function in a PHP class which has the same name as the class?

So I am getting started with OO PHP, and after reviewing a variety of classes which I have downloaded from the internet, I have noticed that some - but not all of these classes have an intial function with the same name e.g. class MyClass{ function MyClass{ //function contents in here } function otherfunction{ //more stuff here } ...

Convert MySql DateTime stamp into JavaScript's Date format

Does anyone know how I can take a mysql datetime stamp, such as YYYY-MM-DD HH:MM:SS and either parse it or convert it to work in JavaScript's Date() function, such as.. Date('YYYY, MM, DD, HH, MM, SS); Thank you! ...

Failed to connect to mailserver at "localhost" port 25

I have a little problem. When I click send on my contact form I get the following warning: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() I use 64bit Win7, but I have no idea what should I set up to make this work. ...

Coordinates system (PHP an array)

I have point A(x,y) and B(x,y). they listed as array (a => array(x,y), b => array(x,y)) How get lenght between point A and B. Please help in php. :) ...

excluding certain files from a search within an array of names

This function grabs all the jpegs from folders which match the page name and prints a background image. On the homepage it searches all the sub directories and chooses one at random. What i would like is to exclude (on the homepage only) certain files which match an array of names...can anyone help? $isHome = $this->level() == 0; $pa...

how do i check all elements of an array are the same?

ie, verify $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; but not $a[0]=1; $a[0]=2; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; $a[0]=1; thanks :) ...

PHP : How to ensure script does not fail if method does not exist?

I have a PHP script which calls methods from a class I have written. However due to the nature of the system there are occasions where the method called does not exist e.g $snippets = new Snippets(); echo $snippets->fakeMethod(); in the above example fakeMethod() does not exist and the script fails with a fatal error and stops altoge...

Checking if mySql datetime is older then 1 day from php now()

Hi, I have a record returned from MySQL that has a datetime field. What I want to do is take this value and see if it is older then 24 hours, I presume using PHP's time() to get the current time. At the moment if I echo them out I get: 1276954824 this is php's time() 2010-06-19 09:39:23 this is the MySQL datetime I pre...

how do i create a transparent canvas, then add transparent pngs to it?

i need to create a transparent image, then combine transparent pngs to it whilst maintaining image quality. how can i do this? imagecreatetruecolor(...); //processing using imagecopymerge(..); imagepng(...); outputs a black background. thanks :) here's my actual code for reference... $d = getimagesize(TMP.$this->files[0]);...

PHP mail: use quotes in $to and in from mail header or NOT?

Do we need to use quotes in $to and in from/cc/bcc mail headers when using PHP mail function? I mean, let's say I want to send mail to: User One <[email protected]> Do I have to call: mail("\"User One\" <[email protected]>", ... OR mail("User One <[email protected]>", ... I suppoose once you give me an answer for the $to, it is going...

How long until MySQL transaction times out

How long can a MySQL transaction last until it times out? I'm asking because I'm planning to code an payment process for my e-commerce project somewhere along the lines of this (PHP/MySQL psuedo-code): START TRANSACTION; SELECT...WHERE id IN (1,2,3) AND available = 1 FOR UPDATE; //lock rows where "available" is true //Do payment proce...

Problems with SolrPhpClient Delete function

Hi, I am having some trouble deleting documents from Solr index. I use following code: try{ $solr->deleteById('1'); $solr->commit(); $solr->optimize(); }catch (Exception $e){ echo $e->getMessage(); } This code sometimes succeeds, but most of the time the following exception message is retur...

Fiddler, localhost, IIS, PHP and GData

Hi I have managed to get Fiddler monitoring my localhost traffic by specifying my machine name. I am using IIS7 (localhost) on Vista business. I'm developing using PHP and am currently using the Zend GData framework to communicate with Google Calendar. I am not seeing any communication between the IIS/Localhost server and the Google se...

Problem with header in php

Consider the following code <?php $username = "root"; $password = ""; $host = "localhost"; $database = "binaries"; @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error()); @mysql_select_db($database) or die("Can not select the database: ".mysql_error()); $id = 5; if(!isset($id) || e...