php

php/mysql: database of bank holidays and events like christmas, easter etc...

Hi guys, Im working on a simple calendar application and i want to have the above events display on the calendar [bank holidays and that]. The calendar is just a standard month view, with a link to view each day for each day in the month, and links to view next/ previous month and year etc... i will probably have the mktime for each e...

PHP 5.2 and PHP 5.3 side-by-side in vHosts on the same Apache (Debian)?

Possible Duplicate How can one run multiple versions of php5.x on a development lamp server Is there a chance to have various versions of PHP (right now I'd like to have 5.2 and 5.3 side by side) running on the same machine just within different vHosts? I'm running a Debian server and the PHP packages come from dotdeb.org - is ...

PHP Templating Looping Results

Hey! So here at work we have a home grown templating system, that is light weight and works great for us so far. The wall we're hitting is that we want to be able to loop over a template. The use case is something like search results. We are trying to think of ways that we could do this. We've come up with three ways right now. F...

How to best store user information and user login and password

I'm using Mysql and I was assuming it was better to separate out a users personal information and their login and password into two different tables and then just reference them between the two. Note : To clarify my post, I understand the techniques of securing the password (hash, salt, etc). I just know that if I'm following practices ...

Why do images served from my web server not cache on the client?

I store all of my images behind the webroot (before /var/www/), which means that the web server is unable to send cache headers back for my pictures. What do I need to add to this to make the user's web cache work? Currently, this is getting hit every time by the same browser. My <img> path on my pages look something like this: <img s...

how to sort query result in php?

Hi, I am trying to sort query result into an array. I have following query. "select s.*, a.* from students left join addresses as a"; it returns s.id s.name a.id a.student_id a.address I would like to make above result into an array with s and a keys. array( "s"=>array("id"=>"value","name"=>"value") ,"a"=>array("id"=>"value...

Why doesn't file_exists() work?

Here is my PHP code: [root@file htdocs]# vi test.php <?php var_dump(file_exists('/usr/local/apache2/resumes/28/"Chapel Hill"/franky_li/"CV.doc"')); ?> "test.php" [New] 5L, 100C written [root@file htdocs]# php test.php bool(false) which says the file doesn't exists,but in fact it does: [root@file htdocs]# ls -l /usr/local/apache2/r...

how to know whether preg_replace() didn't match or matched from start?

both conditions returns false,how to distinguish them? can it be done without using the third parameter? ...

Carrying row values from MYSQL after form submission.

What is the best way to carry an auto incremented ID from one form to another? I have 3 tables (users, residences, and users_residences). I want a user to register, be added to the users table, be redirected to a form to create a residence which will add a row to the residence table and simultaneously add the the residence tabe row's i...

how to implement a decorator in PHP?

Suppose there is a class called "Class_A", it has a member function called "func". I want the "func" to do some extra work by wrapping Class_A in a decorator class. $worker = new Decorator(new Original()); Can someone give an example? I've never used OO with PHP. ======================================================= Thank you g...

[Mysql] Is there a way to prevent duplicate entries in a table pivot/mapping?

I'm relatively new to MySQL, and I was wondering if it was possible to prevent duplicate entries in a table pivot/mapping which has no primary key and a many-to-many relationship. A simple example: table 1 table1ID field field table 2 table2ID field field pivot table table1ID table2ID Since a many-to-many relationship would mean tha...

How do I parse XML from PHP that was sent to the server as text/xml?

I have a client-side script written in jQuery that is sending text/xml data to the server, but I can't figure out how to parse the request since the data is not a query string variable. The jQuery looks like this: jQuery.ajax({ url: "test.php", type: "POST", processData: false, contentType: "text/xml", data: xmlDoc, ...

Finding difficult when i post xml document in my site

hi friends I am using a php and javascript codes to post my xml to a url. and i have posted it successfully from my local server. but when i tried it in site, i cant post my xml document to that url. what will be the reason for it??? why this is happening, working perfectly in my local server but nothing is happening in the site. i...

How to keep PHP 'View Source' html output clean

This has been bugging me today after checking the source out on a site. I use PHP output in my templates for dynamic content. The templates start out in html only, and are cleanly indented and formatted. The PHP content is then added in and indented to match the html formating. <ul> <li>nav1</li> <li>nav2</li> <li>nav3</li> </ul>...

Passing data from MVC Controller to View in PHP

I have my own hand-rolled PHP MVC framework for some projects that I'm working on. When I first created the framework, it was in the context of building an admin CMS. Therefore, there was a very nice one-to-one relationship between model, view, and controller. You have a single row in the DB, which maps to a single model. The controller ...

Are there any way to know whether user open mail ?

we build newsletter module, and send email to members. The environment is LAMP. Are there any way to know whether member open the mail ? i hear about put image if 'php' source , what is the best way? ...

How can I do a global regular expression match in Perl?

I am trying to come up with a regular expression in Perl matching multiple patterns and returning all of them like preg_match_all in PHP does. Here's what I have: $str = 'testdatastring'; if($str =~ /(test|data|string)/) { print "its found index location: $0 $-[0]-$+[0]\n"; print "its found index location: $1 $-[1]-$+[1...

How to determine that an Ajax request is older than 5 minutes in PHP?

I am developing one site, and I want to ensure that Ajax requests which are older than 5 minutes are not executed. This means that I want to execute only fresh Ajax requests. How can I do this? ...

Best way to update user rankings without killing the server

I have a website that has user ranking as a central part, but the user count has grown to over 50,000 and it is putting a strain on the server to loop through all of those to update the rank every 5 minutes. Is there a better method that can be used to easily update the ranks at least every 5 minutes? It doesn't have to be with php, it...

how to enable sqlite3 for php?

Hi, I am trying to install sqlite3 for php in ubuntu. I install apt-get php5-sqlite3 and edited php.ini to include sqlite3 extension. When I run phpinfo(); I get SQLITE3 SQLite3 support enabled sqlite3 library version 3.4.2 as shown above, sqlite3 is enabled. However, I get "Class SQLite3 not found" when I use new SQLite3("dat...