php

What is the most elegant way to do "foreach x except y" in PHP?

I want to do something like this: foreach ($array as $key=>$value except when $key="id") { // whatever } ... without having to put an "if" clause inside the body of the loop. It is not guaranteed that "id" will the be the first or last element in the array, and I don't really want to unset or slice the array, because that will be expe...

How to go about speed testing my PHP script?

I have a script that is running slowly and I was wondering how I could time it and see which fixes improve the speed. Is there some sort of a PHP timer? Update: Thought I should clarify... The script that is running slowly is my mailing list script that sends an email to everyone on the list. So I am looping through an array of subscrib...

Are there any free cmd-line scripts which can re-format PHP source-code?

I'm using a pre-commit hook to lint-check PHP source submitted by our staff, and everyone's really happy with the results. The staff have agreed it would be useful to have the code re-formatted to follow (customizable) style rules on commit. Are there any FOSS scripts which can do this from the command-line? ...

Which PHP Web framework for Firebird?

Is there any PHP web framework that works cleanly with the Firebird database? By "cleanly", I mean out-of-the-box, no hacks/customization/self-made drivers. So far, I've checked out frameworks like CodeIgniter & CakePHP, but their support for Firebird is vague or little at most. ...

JavaScript tag is generating break in HTML code

I got this JavaScript tag which is displaying a banner on my page: <script src="http://e2.emediate.se/eas?cu=10524;cre=mu;js=y" language="JavaScript" type="text/javascript"></script> <embed height="150" width="768" type="application/x-shockwave-flash" src="http://e2.emediate.se/media.2/170/4045/32676/49312404-768-150....

How to delay the dispatch of an e-mail? Click button to send NOW but wait until 6.00pm until the email gets actually sent.

I have a php script that does some processing (creates remittance advice PDFs, self-billing invoices, Sage CSV file etc...) and at the end outputs a screen with a form, in which the names and e-mail addresses of the people paid appear. User makes a selection of names by clicking check boxes and then there is a Send button which sends out...

Mail returns false

I'm currently using a custom made library at my job. Until just rencently the library was working perfectly. It apparently return false since about today. The library itself it basically a wrapper around the function mail. It builds the "boundaries" parts and everything. Since the class is quite big enough I wont post it here ... but I...

Calling Parent Class From Sub Class PHP

Hello There http://stackoverflow.com/questions/742097/this-a-b-c-d-calling-methods-from-a-superclass-in-php Ive asked a question on this link I ve problem with this tecnique I am able to call the sub classes from a class like this $chesterx->db->query(); I wanna do get another class from sub class for example i want to query exe...

MVC - How does it work in the real world?

I've read a lot of trivial MVC examples of calculators and thermometers but I can't seem to map the pattern to real world applications. Suppose you have a more complicated scenario. Say you have a website shopping cart which requires users to login before adding to the cart. First, the user sees the product page (/product/detail) and cl...

including files without having to specify $_SERVER['DOCUMENT_ROOT']

Hi... Before the PHP Version update I used to be able to include files as following without specifying the document root: <?php include '/absolute/path/to/files/file1.php'; ?> However I now have to include the same file as following: <?php include $_SERVER['DOCUMENT_ROOT'].'/absolute/path/to/files/file1.php'; ?> What php.ini setti...

Migrating technologies: PHP+MySQL -> ASP.NET MVC+MS SQL 2008

I have a completed web app in PHP 5 + MySQL. I have not yet started its conversion, but it will migrate to ASP.NET MVC + MS SQL 2008. I'm not sure how to progress for the easiest transition: Edit the PHP DAL for SQL Server. Migrate to the new db immediately Leave the live code alone. Create ASP.NET MVC with a MySQL DAL to use for now. ...

[Mysql] Fetch all news and all comments

Hi, I'm trying to code a query that gets all the news and all the comments for each news. My current query is : SELECT n.*, c.* AS comments FROM news n JOIN comments c ON (c.news_id = n.id) But when I fetch the query as an array it gives me a key by comment and I would like to have a key by news and all comments in a s...

How do I loop through a PHP array containing data returned from MySQL?

Ok I have a table with a few fields. One of the fields is username. There are many times where the username is the same, for example: username: bob password: bob report: 1 username: bob password: bob report: 2 I did a SQL statement to select * where username='bob'; but when I do the following PHP function, it will only retur...

Operator Overloading in PHP

Is it possible to overload operators in PHP? Specifically I would like to create an Array class and would like to overload the [] operator. ...

Mod Rewrite and PHP

I am trying to redirect pages using mod_rewrite to the pages with some variables (for using them with PHP's $_GET). To give an example with few lines: When the user enters /c/stg it redirects to item_show.php?id=$1&f=1 (where f is page number). When the user enters /c/stg/2 it redirects to the second page with show.php?id=$1&f=$2. I...

How to connect to the database in Magento?

I'm trying to build a simple Magento Module that needs to connect to the database at the start of each page request. All tables need to be accessible to it. I've been pulling my hair out trying to understand how to do it. The best I could figure out was that I need to set this in the config.xml file of my module, but exactly what that co...

Richtext editor for PHP - MySQL web application

I have a PHP web application inside where i need to have a rich text editor(with basic formating options) for my users to enter data in to the portal. Can any one tell me how to do this ? Will there be any change in the database saving part since i am saving data in a mysql DB Thanks in advance ...

What's the best approach to sending email to hundreds of recipients from a Zend Framework application?

I'm trying to implement a mailing list system for my application. I'm currently using Zend_Mail_Transport_Smtp('localhost') as my transport, looping through my list of subscribers, and sending a new Zend_Mail to each one. However, I am noticing that the length of time that it takes for the script to complete increases as the number of su...

CakePHP's scaffolding questions and changing the language of error messages

I've started to learn how to use the CakePHP framework for a part time job. And I decided to build one of my personal projects in this framework to get some practice on it. I have some models I created using Cake bake command and I added the automated CRUD support (It adds to the controller var $scaffold for the all relevant actions. I...

Ubb forum error Unable to connect to the database!

I have recently migrated my ubb forum website to a new web hosting server, I have placed the files on new server and I think directory structure is right and also set up the database through phpmyadmin, and changed config file accordingly but still I am getting this error UBB Message We encountered a problem. The reason reported was Sc...