php

MySQL DATETIME question

I have a DATETIME field. I would like to select all the records that have been updated in the last week. Right now I'm using this query: SELECT SUM(mins_spent) as time_sum FROM todos WHERE lastUpdate >= '2008-12-22' AND lastUpdate <='2008-12-28' But the results i get seem to be different depending on time of the day, e.g on 7 PM I mi...

PHP set_inlude_path and include best practises

Where would set_include_path("../../"); point to? I am trying to run some PHP code on a standard XAMPP server. And put my stuff into the htdocs folder. The includes point to relative paths, But it does not work. Is there any best-practise for includes? The code has to run on machines of multiple developers. ...

Using knockd to do stuff | Sending TCP/UPD Requests via PHP

I was wondering, whether knockd http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki would be a good was to be able to restart apache without logging into ssh. But my programming question was whether there is a way to send tcp/udp packages via PHP so I can knock via a webclient. I am aware that this is not the safest way of doing it, ...

Honor a cookie in all open tabs

I have a web app that authenticates against a SQL DB and sets a cookie with credentials, like a "remember me" sort of thing. Part of the app involves using a bookmarklet to add things into your personal slice of another DB. This works fine if you authenticate and, in the SAME TAB, begin using the bookmarklet. However, if you authenticate...

Is PHP truly faster on the JVM?

Lately I've been hearing a lot of people evangelizing that PHP with Resin is actually much faster than with mod_php, but I cannot find any benchmark anywhere. Is it true or just vendor BS? ...

What setting might be causing an AMP server to only allow 1 request at a time per browser?

I'm using an AMP server (Apache 1.3, MySQL 5.0, PHP 5.1.5) which I have found to only allow 1 connection/request per browser at one time. The easiest way to reporduce this is to request a large download which is passed through PHP and try to access another page at the same time. You will end up waiting for the first request (the file dow...

Is there any IDE for fast drag and drop php development?

Hi I am using Eclipse IDE with few plug-ins for PHP dev. I am using PHPEclipse plug-in and I know there are lotsa other plugins like EasyEclipse.But is there an IDE like Visual Studio with cool drag and drop stuff for PHP? ...

Is it possible to decrement a variable in MySQL?

I'm wanting to decrement a variable in a MySQL table by one everytime an UPDATE query is ran. What I have is this, which isn't working: UPDATE forum SET replys = reply-- WHERE fid = '$id' Is this possible in any way, or am I going to have to run a SELECT and get the value first, decrement it, and then insert the new value into the UP...

Graphs/Charts in PHP

I'm trying to find a good Graph drawing library for my PHP application. Currently I am limited to viewing the data in a table which while specific, is a bit ugly. I require a non-flash system if possible. ...

URL mapping in PHP?

I come from a Java background and with any servlets-based technology, it's trivial to map a range of URLs (eg /reports/, /secure/.do) to a specified servlet. Now I'm less familiar with PHP but I haven't yet seen anything that does quite the same thing with PHP (or mod_php). It's entirely possible that I'm missing something simple. How...

Is there a PHP equivalent to Java URL filters/interceptors?

One of the things I like about Java servlets is the use of unobtrusive filters and interceptors. Basically you could use these things to enforce security, put extra information on the HttpRequest, do monitoring or whatever. Is there some equivalent in PHP? From what I've seen so far it seems that you tend to include a certain file in ...

How to get code point number for a given character in a utf-8 string?

I want to get the UCS-2 code points for a given UTF-8 string. For example the word "hello" should become something like "0068 0065 006C 006C 006F". Please note that the characters could be from any language including complex scripts like the east asian languages. So, the problem comes down to "convert a given character to its UCS-2 code...

PHP vs. application server?

For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP? I tend to favor PHP simply because it's available on just about any web server (especially shared ho...

Allowing Only Certain Characters In PHP

I need to check to see if a variable contains anything OTHER than a-z A-Z 0-9 and the "." character (full stop). Any help would be appreciated. ...

PHP: I want to create a page that extracts images from a forum thread, doable? codeigniter?

You have a forum (vbulletin) that has a bunch of images - how easy would it be to have a page that visits a thread, steps through each page and forwards to the user (via ajax or whatever) the images. i'm not asking about filtering (that's easy of course). doable in a day? :) I have a site that uses codeigniter as well - would it be eve...

Does moving to Symfony 1.1/1.2 make sense?

I built an on-demand web app on Symfony 1.0. Other than brutal memory consumption, I am happy with it. Should I upgrade to 1.1/1.2? What are the main practical benefits you have enjoyed most after upgrading? ...

Access PHP array element with a function?

I'm working on a program that uses PHP's internal array pointers to iterate along a multidimensional array. I need to get an element from the current row, and I've been doing it like so: $arr[key($arr)]['item'] However, I'd much prefer to use something like: current($arr)['item'] // invalid syntax I'm hoping there's a function out ...

preg_match_all() [function.preg-match-all]: Unknown modifier ']'

Using a few different patterns but they each come up with this error - so what's wrong? My shortest one to diagnose is: $pattern = "<img([^>]*[^/])>"; preg_match_all($pattern, $subject, $matches); Thanks ...

Force PHP to error on non-declared variables? In objects?

Is there any way to force PHP to blow up (error, whatever) if I misspell a variable name? What about if I'm using an instance of a class and I spell the name of a variable wrong? [I know that I should just get used to it, but maybe there's a way to enforce name checking?] Thanks! Edit: Sorry, that wasn't very specific. Here's the cod...

Getting a PHP DateTime object into a string representation of a MYSQL date

I have a DateTime which I want to store in a Date MySQL column. I am using MySQLi and prepared statements. When binding parameters, I cannot specify date as a type, only strings and integers. How do I convert the DateTime to a MySQL date string representation? There is very little documentation on the DateTime class. ...