php

Getting all dates for Mondays and Tuesdays for the next year

I need to output a list of dates (only Mondays and Tuesdays) for the next 12 months from current date like so: Jan 2010 Tue 12 Jan 2010 Mon 18 Jan 2010 Tue 19 Jan 2010 Mon 25 Jan 2010 Feb 2010 Tue 02 Feb 2010 Mon 08 Feb 2010 Tue 09 Feb 2010 Mon 15 Feb 2010 Tue 16 Feb 2010 Mon 22 Feb 2010 Mar 2010 Tue 09 Mar 2010 Mon 15 Mar 2010 Tue 1...

PHP_ParserGenerator - bug in grammar or in the parser generator?

I'm trying to create a parser for a simple language with the lemon port to PHP, and it works, almost. The following grammar: %name SP_ %declare_class { class SpecParser } %token_prefix SP_ %include_class { public $retvalue = '<todo: error handling>'; public function singleKey($elem) { end($elem); return key($elem); } } %pa...

MySQL Query for displaying all rows of one table with yes/no if matching other table?

I apologize in advance for the non technincal description on this problem! I have two tables: UsersOptions and OptionsList.. For simplicity sake, OptionsList is below: ID - NAME 1 - Red 2 - Blue 3 - Orange UsersOptions has many rows eg; ID - CLIENT - OPTION 1 - John - Red 2 - John - Orange 3 - Mary - Red 4 - Jill - Blue 5 - Jill ...

PHP empty() on __get accessor

Using PHP 5.3 I'm experiencing weird / non-intuitive behavior when applying empty() to dynamic object properties fetched via the __get() overload function. Consider the following code snippet: <?php class Test { protected $_data= array( 'id'=> 23, 'name'=> 'my string' ); function __get($k) { return $this->_data[$k]; ...

PHP Add up a series of minutes:seconds

I have a list of video segment durations I need to add up to get the total duration. The series is like this: 0:33 4:30 6:03 2:10 ...etc I need to add up the minutes and seconds to get a total video duration. Here's the modified function of my accepted answer: function getTotalDuration ($durations) { $total = 0; foreach...

Using SOAP to generate XML attributes in PHP

I found you can generate this in SOAP in php: <foo bar="blah">12345</foo> With this: array("foo" => array("_" => 12345, "bar" => "blah")); However, the underscore method does not seem to work when the value is not a number and string, but instead embedded xml code. How would you do this for instance? <foo bar="blah"> <aaa a="...

Pass by reference problem with PHP 5.3.1

Ok, this is a weird problem, so please bear with me as I explain. We upgraded our dev servers from PHP 5.2.5 to 5.3.1. Loading up our code after the switch, we start getting errors like: Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /home/spot/trunk/system/core/Database.class.php on line ...

PHP 6 - Roadmap ?

Has anyone found a roadmap for PHP version 6? Also, any very rough ETA on the release date (please don't answer "when it's ready", I'm just trying to get a sense of if it's first half of 2010, second half, etc) ...

Some problems searching mysql database via php

So I have this website that has a search feature which searches a table in my mysql database. The database at the moment has 1108 rows. It contains music info such as Artist and Album. Since its possible for every character to be in an artist name or album name, I've urlencoded each of those variables before being added to the database. ...

How to run the equivilant of PHP and MySQL on portable media (eg CD, USB and/or iPhone)

I use a local installation of Apache, MySQL, and PHP with XAMPP which require a bit of configuration and installation - is there an alternative language or database system that can be used on portable media such as a CD or DVD-Rom? Although this question is similar to apache-php-and-mysql-portable - I'm looking more for the best portable...

Representing text with number MySQL

Hello, I am building a survey, in which participants use a html form to enter details. For example: What gender are you? Male | Female The Male/Female option can be selected using a radio button. However, I would like to store the answer in my database as an INT value, which is 0 for male and 1 for female. How do I write a quer...

How to compile PECL mailparse for Windows x64

My Cerberus installation fails when testing the php_mailparse lib. After some research, I understand that PECL does not supply an x64 version of their dll for windows. Can anyone provide instructions on how I might go about compiling the following lib for x64? Is VS my best option and if so, a quick overview would be very helpful. lin...

Anyone have experience integrating with MYOB?

Looking to integrate a web application with MYOB. There's not much in terms of documentation out there. I've found a couple of companies that provide middleware, but nothing promising. Just thought I'd see if anyone else out there has had experience with this and might be able to save me a bit of time. Cheers ...

What is "enough sanitization" for a URL

The URL would be Saved to a MySQL database Used to display a picture on the user's profile would strip_tags() and mysql_real_escape_string() be enough? ...

How do I get the page source of the html page using php codes?

How do I get the page source of the html page using php codes and then save all all of those codes into a database? Is it possible? Please help. Thanks. Database is MySQL ...

why does this always die ?

$extension = "jpg" if($extension != "jpg" || $extension != "gif" || $extension != "png") die("only jpg, gif, png acceptable"); it always seems to die(). ...

PHP Socket accept_connection hanging

I recently found out that PHP not only has the fsock* functions, but also functions to create a server itself. I decided to experiment a little bit, and came up with this. Now, the problem is that it hangs on accept_connection() (due to the fact that it's waiting for a connection.) I found out that the solution is to use stream_set_block...

do things with the return value of smarty function?

We have this Smarty function that returns HTML code for templates. However it is also possible that the function returns a null string, which we now wish to identify. Our system has been running stably for years, so I am looking for the least invasive possible solution. Is it possible to assign the return value to a smarty variable? I h...

How would I remove all spaces between single quotes skipping escaped quotes in PHP

Exactly as the title asks: How would I remove all unnecessary spaces between single quotes skipping escaped quotes in PHP? I am looking for a fast implementation to pre-prep for parsing. I would prefer not to use regex if it would be slower than using a simple loop. (The double quotes below are for display purposes only) examples wo...

script runs fine when run from command line but not via cron

i have a php script which runs fine when executed by SSHing into my server and running it. however the php script doesn't seem to run even though a cron job set to run it every 10 minutes. How do I view errors produced by cron job ? ...