php

pdo_mysql vs mysqli when using Zend_Db

If I am using Zend_Db classes to abstract my queries from the backend database, does it make a difference which mysql driver I use, pdo_mysql vs. mysqli? My understanding of pdo_mysql is it is also to provide abstraction, so I'm assuming that if I am using Zend_Db, then I would not be taking advantage of the extra features as part of mys...

Best way to get hostname with php

I have a php application that is installed on several servers and all of our developers laptops. I need a fast and reliable way to get the server's hostname or some other unique and reliable system identifier. Here's what we have thought of so far: <? $hostname = (!empty($_ENV["HOSTNAME"])) ? $_ENV["HOSTNAME"] : env('HOSTNAME'); ?> <...

PHP - How to start a session after HTTP authentication.

I am dealing with the skeleton of an old website that uses http authentication for users to access membership data. The access content button is a link to a index.html page with the following: <meta http-equiv="REFRESH" content="0; url=http://www.example.com/something.php"&gt; I would like to change this to a index.php page which woul...

Is PHP dynamic enough?

As far as I know, PHP is a dynamic type language. We don't need to declare variable and don't need to define data type of variables and function return. I found an article on sitepoint and one commenter said PHP is not dynamic enough because... PHP does to many things at compile-time (like the whole “static” “self::” stuff) inst...

Does file caching make sense when using Sqlite DB + PHP ?

Hi Folks, does it make sense to use an Filecache when using Sqlite as Database ? Lets say the Database and the Cache is one the same Harddisk (no Raid) ? ...

Sending an invite email with an HTML form and a PHP script

Hello, After a user adds 5 emails and their name to form below, and then hits the "send" button, I would like to send a message such as "Hello, your friend 'sendername' recommends that you use thissite.com. Please visit the site." I would also like to specify the from address that this email has on it. What PHP script could do this? ...

PHP check which directory/ php scripts are loaded

Is there anyway for this PHP script to know what are the scripts or directories that are currently loaded? I am talking about my scripts, not specific module The reason I ask this is because, due to the layers and layers of includes ( now don't get me started on what include or include_once is bad), and due to autoloading, it's kind of ...

Creating sound - reading out alphabets - in PHP

Hi all. I've been doing a captcha script lately and was rather successful with it. However I want to create another script that creates a sound which can be used with the captcha. E.g. the captcha script generates A2B1FD - and the sound script must be able to read out A, 2, B, 1, F, D. How do I go about doing this? I know it's somethi...

Making an PHP application that updates itself and protecting it on an enterprise level

Hi all, I'm building a CMS application in PHP. How can I make it update itself? For example via a zip file or something similar. So that an user can see new releases and download / install them without using a FTP program at all. What's the best way to protect my application? So that the user can't share it with friends. I know that a...

PHP Namespace and Include() with classes

Hi Community, there is a project which I need to extend. All classes are in seperate files, I need to extend some of the classes without rewriting existing code in other files. My idea was to use namespaces but I fail. Here is an example: I've renamed the original A.php class file to A_Original.php: class A { public function hell...

PHP Spam score calculator?

Is there software that can give an email, with full headers, a spam score? What do most people use? I've seen places like mailchimp.com show a spam calculator. What do they use to determine this score? ...

Missing Helper file error in cake php on shared hosting

I am getting a Missing Helper error when I am trying to upload my cake php files to a shared host. Undefined variable: javascript Missing Helper File It is working fine on my local machine. I have the following directory structure in shared hosting:(using cpanel) /home/user/ /app /cake /vendors /public _html /css ...

Am doing online Quiz type of script in PHP. It is better to use cookies or sessions.

Hi all, Am doing online Quiz type of script in PHP. User needs to attend 50 Question in 45 minutes. After that time it should close the page or Submit the answer to the next page. It is better to use cookies or sessions. How can i do that. Am novice in session concept so can u suggest the suitable code. Awaiting the earliest reply...

Apache: reverse proxy to process PHP from another server

I have the following setup: Plain-Server: Delivering php-files as plain text Proxy-Server: Asking the Plain-Server for the php file and parsing it. Now my question: How do I configure the Proxy-Server (a fully configurable apache 2.2 with PHP 5.3) to interpret the plain php files from Plain-Server? Example: Given a small php script ...

php Timestamp working logic

what is exactly happing when creating a Unix Timestamp from a given date. I want the step by step method to create timestamp. (not using php built in functions). EDIT: What is the specialty of this date :) January 1st 1970 00:00 h UTC ...

How to write a php/htaccess script to redirect form variables to another website

Hey here is my problem : i made a flash and i can`t change it no mather what. That flash had a form that was sending data to my subdomain.. i had to remove the subdomain and i got a new website, the problem is this : how do i redirect the form data from the old site to the new one? In the flash i had the form send the data to : subdomain...

Getting excerpts from sphinx with the php api

I'm trying to get sphinx search to return excerpts of matched documents. I'm using http://code.google.com/p/sphinxsearch/source/browse/trunk/api/sphinxapi.php to speak with the sphinx daemon. At the moment I'm only getting back the following: [matches] => Array ( [28] => Array ( [weight] => 2 ...

PHP MYSQL multiple or single DISTINCT/UNIQUEvalues

Currently I have this query: SELECT column1,column2 FROM table column1 needs to be distinct, column2 does not. SELECT DISTINCT column1, NON-DISTINCT column2 FROM table Now I know that doesn't make sense but I need column1 to be distinct and column2 to be anything. How would I do that. ...

Custom products in Drupal or OSCommerce?

I've looked high and low. I think I'm not searching for the right stuff. I want to know of a module, or plugin for either drupal or oscommerce that will allow you to "build your own products". I.e. A customer can go on the site, and say he wants PC A, with X amount of RAM, and Z sized harddrive etc. Is there a plugin or module for eit...

drupal_add_css not working

I need to use drupal_add_css to call stylesheets onto single Drupal 6 pages. I don't want to edit the main theme stylesheet as there will be a set of individual pages which all need completely new styles - the main sheet would be massive if i put it all in there. My solution was to edit the page in PHP editor mode and do this: <?php d...