php

Is SAJAX dead? What to replace with?

We use Sajax for adding small Ajax code to sites. After running into a problem and doing some digging, it seems the library hasn't been updated since 2005. I've appreciated Sajax for being lightweight, easy to use, and easy to install (just include the file in PHP). So, on the LAMP stack, if you have used Sajax before, what would you...

Are php strings immutable?

Or: Should I optimize my string-operations in PHP? I tried to ask PHP's manual about it, but I didn't get any hints to anything. ...

Popularity Algorithm

I'd like to populate the homepage of my user-submitted-illustrations site with the "hottest" illustrations uploaded. Here are the measures I have available: How many people have favourited that illustration votes table includes date voted When the illustration was uploaded illustration table has date created Number of comments (n...

PHP If else statement that a database record is empty it will display a default picture.

Hi basicly I am trying to create a simple IF statement that shows a default picture if one hasn't been entered in to my database. I am using server to store my picture and a database to store the file name, so I can get the image to display if it has a file name in the db but I want the If statement to say if the record is empty display ...

Data mapper pattern and automated updates of other objects

Hi, I'm building a PHP application using the data mapper pattern to separate my DB from the domain objects. I have a mapper class that returns Site objects based on data from the DB and accepts existing Site objects to be saved back to the DB. My problem is that in the system one (and only one) of all the sites has to be marked as the ...

Nusphere PHPEd: PHP Function Hints Lost Arguments?

Hi All, My PHPEd suddenly stopped showing arguments and arg order in the hints, and now just shows a basic description of the function. Before I go digging around in the config files, has anyone else had this problem? Thanks! Edit: Sorry, I may not have been entirely clear on this. There is no problem with my own classes, only with...

PHP library to read PDFs ?

Do you know of any free libraries to read PDFs in PHP, the built in PDF functionality is only for rendering PDF output. ...

How to check if a function is callable with parameters?

I'm calling a function with call_user_func_array : call_user_func_array(array($this, 'myFunction'), array('param1', 'param2', 'param3')); Everything is ok unless I don't know how many parameters the function needs. If the function needs 4 parameters it sends me an error, I'd like to test if I can call the function (with an array of pa...

How should I design the interface to a SQL column generator in PHP?

I'm working on a framework in PHP, part of this frameworks job is to write SQL code to generate new MySQL columns. What is the most elegant way to pass in a bunch of parameters for a column and then turn that into SQL code? As an example here is some YAML I have, that specifies parameters for creating a varchar column: - type: characte...

Map URL to MySQL databases

I am interested to offer both hosted and SaaS version of my application. Now, SOers suggested that I map the URLs to MySQL databases. What I can think of is something like this companya.mysoft.com will have the MySQL database that starts with the name companya*. i.e., compana_mydb companyb.mysoft.com will have the MySQL database that s...

wordpress url resolution of subpages from within plugin

Say I have a Page "foo" in wordpress such that http:/www.blah.com/foo brings it up. Say this page has a trigger within its content such as <!-- foo --!> which is being tracked by my plugin through the add_filter('the_content', ..) filter. So, all calls to http:www.blah.com/foo and http://www.blah.com/foo?var=bar are picked up by the plu...

Charting libraries in PHP output to SVG or Canvas?

I'm looking for a charting library written in PHP that outputs to SVG (or Canvas), possibly for integration into an ExtJS project. I like the look of http://pchart.sourceforge.net/index.php but it does bitmap output and is GPL licensed, which will probably be a show-stopper since the project is an internal commercial project. Any sugges...

Using jquery .ajax to retrieve records from mySQL DB

I am a mySQL noob, and have a slightly stupid question... I am using jquery to send form to a php script which then stores the data in a mySQL database. On another page in my app, I need to get all the values from one column of said mySQL DB, using jquery again (I assume I will also have to write another php script) so I can use the re...

Going to a Random page PHP

I have a link that goes to http://example.com/random.php, code for random.php below. <?php srand ((double) microtime( )*1000000); $random_number = rand(1,100); header( "Location: http://example.com/test?page=$random_number" ) ; ?> Basically what I want it to do is link to a random page. It works initially, but after the first click i...

PHP serving one page at a time

I'm running an Apache 2 and PHP 5.2 configuration, and for some reason, PHP can only serve one page at a time. I have two pages which best illustrate the problem: test1.php and test2.php. test1.php only has sleep(120) in it, test2.php has a simple 'print "hello world";' in it. If test1.php is currently loading in a browser window, an ...

PHP security : retrieving PHP file from server, un-processed

Is there really a way to do this ? Retrieving raw .php file from the server (other than getting into server's FTP account) ? Is this the reason why there are tools/script to encrypt php source code ? If it's true, then how to protect against it ? (without using php source code encryption) edit: the server mentioned has php running, eg....

Most elegant solution for humungous problem

I'm working on a site where a user could select certain dates that apply to them, e.g Date 1,Date 2, Date 3, etc. Each date will have certain questions belonging to it, so if the customer checked off 'Date 1' to indicate that this date applies to him, he'll then see a bunch of textboxes asking him about Date 1 and how it applies to them...

PHP Constant doesn't exist: Notice

Hi, I'd like to use constants as config variables within my PHP applications, only when an constant doesn't exist (for whatever reason) it throws me an notice but i'd like that to be a error (or exception) just like when i try to echo a not existing variable. Is that possible without using a seperate function for getting constant value...

I need to change the date format using php.

Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line echo "<td><strong> ("d/m/y",". $row['date'] .")</strong></t...

Intranet back-office data on the webserver?

I am upgrading a client's e-commerce webstore and have hit a bit of a snag. The store is a custom-made set of PHP scripts. At each sale, the credit card is charged via the merchant account interface, and then the order is e-mailed to the client's desktop INBOX. However, as the company grows, this became unscalable, as the client spends ...