php

PHP Not Recognizing http_get_request_headers()?

I'm calling http_get_request_headers() in a PHP file on a server running PHP 5. However, I'm getting Fatal error: Call to undefined function http_get_request_headers(). Does anyone know what the problem might be? Does this function not come with plain PHP? ...

What is the best approach to list a user's recent activities in PHP/MySQL?

I want to list the recent activities of a user on my site without doing too many queries. I have a table where I list all the things the user did with the date. page_id - reference_id - reference_table - created_at - updated_at The reference_id is the ID I need to search for in the reference_table (example: comments). If I would do a ...

ODBC Connection to iSeries Giving Odd Number of Results

I'm using UnixODBC with PHP 5.2.4 on Ubuntu 8.04 LTS and trying to pull all the results from a table sitting on an iSeries and replicate them to a local MySQL table. Code-wise it is working with no errors but I'm ending up with more rows that what is contained on the iSeries. I should end up with 25,613 rows but PHP reports that 25,6...

Manage multiple websites from one domain

Hello, I have been looking for a while now to find a solution to accomplish the following system. I would like to build a PHP system on, let's say, domainA. On this domainA I will allow an administrator to 'create' a new website. This website contains only of pieces of text, which are all stored in a database. This, I know how to do. ...

Getting basepath from view in zend framework

Case: you're developing a site with Zend Framework and need relative links to the folder the webapp is deployed in. I.e. mysite.com/folder online and localhost:8080 under development. The following works nice in controllers regardless of deployed location: $this->_helper->redirector->gotoSimple($action, $controller, $module, $params)...

What's the best way to add a URL parameter to switch views with Zend Framework?

Hi, I'm developing a mobile site using Zend framework, and the site has two possible output formats (WML and XHTML). I'm using the same models and controllers, and then just setting which view to render with in the controller. At the moment, this is decided on by the HTTP Accept header. This needs to be definable in the URL as well. The...

Dynamic Titles

I have a site that has a main page and subpages for the articles comments. What I want it is for the titles of the pages of the comments to be the same as the article's page title. So I have this on the page file, the base for all the comments pages: class Page { private $title; private $scripts; private $css; functi...

PHP: how to grab an URL out of a chunk of text?

Let's say I have a big RSS feed full of Twitter posts, and they are all plain text. Lots of the posts contain URLs, and I'd like those URLs to be turned into links. So I've got a variable that is equal to: Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW...

Strip out ad from html string

I have a variable containing html string. This string has this particular code <a href="http://www.pheedo.com/click.phdo?s=xxxxxxxx&amp;amp;p=1"&gt;&lt;img border="0" src="http://www.pheedo.com/img.phdo?s=xxxxxxxxxx&amp;amp;p=1" style="border: 0pt none ;" alt=""/></a> Using regex, how can I remove that. Basically looking for the phe...

Why do I get the MySQL Error "Query was empty"?

$id = $_REQUEST['id']; $Section = $_REQUEST['section']; $Subject = $_REQUEST['subject']; $type = $_REQUEST['type']; $Start_date1 = isset($_REQUEST['startTxt'])?($_REQUEST['startTxt']):""; $Venue = isset($_REQUEST['venTxt'])?($_REQUEST['venTxt']):""; $Facilitator = isset($_REQUEST['faciTxt'])?($_REQUEST['faciTxt']):""; $Level = isset($_RE...

What's a good strategy for renewing the expiration of a forms auth ticket between .net and php?

I'm creating an application that will get the contents of a cookie storing a forms authentication ticket from .net. That part is done. In that ticket is an expiration time, by default 20 minutes. So the scenario is, a user logs in and is validated on the .net side. Then they are redirected to my PHP app. I get the username, ticket expi...

What are the important differences between using fopen($url) and curl in PHP?

I'm writing some code that will need to speak to a web service over HTTP(s). In the past I've used the curl library. Recently, I noticed that I can simply use fopen() to access a remote URL and it seems far simpler. Curl seems to be much more configurable, having a plethora of options. Beyond that configurability, does it matter whic...

Linking multi-database information

What are your methods of linking data spread over multiple databases architectures (think MySQL vs PostgreSQL etc), into a single application? Would you create giant hashtables/arrays to match content against one another? Are there other, more effective and less memory-consuming options for doing this? If you were to use data both fro...

Is there any Java equivalent of PHP's http_build_query function?

I have a Map with my data and want to build a query string with it, just like I would with http_build_query on PHP. I'm not sure if this code is the best implementation of it or if I'm forgetting something? public String toQueryString(Map<?, ?> data) throws UnsupportedEncodingException { StringBuffer queryString = new StringBuffer()...

Any pitfalls with this regex that matches ampersands not already encoded

In PHP, I want to encode ampersands that have not already been encoded. I came up with this regex /&(?=[^a])/ It seems to work good so far, but seeing as how I'm not much of a regex expert, I am asking if any potential pitfalls can be seen in this regex? Essentially it needs to convert & to &amp; but leave the & in &amp; as is (so as...

Changing WordPress URL structure while maintaing the proper 301 redirects with mod_rewrite

I currently have a blog set up with WordPress using URLs like so: www.domain.com/blog/?pid=384092817 This was before I knew anything about anything. There's a significant amount of content there now and I want to change my URL structure to: www.domain.com/my-post-title-384092817 Is there a way to set up my .h...

How safe are php's native functions to use with unfiltered input?

Maybe I am being a bit paranoid, but as I am re-writing a contact module, the following question came to mind: Can I use unfiltered input in php's native functions? It is easy to sanitize stuff to put in a database, output to the screen, etc. but I was wondering if for example the following statement could be dangerous: if (file_e...

Is require '/home/../http/' as fast as require '/http/' ?

I know that it is poor performance to use relative paths when including a file in php. But, is this true for for all paths or just paths relative to the assumed (context) include path? Is this line require '/home/../http/test.php' as fast as this line require '/http/test.php' ...

Replace 'keys' in file with DB data

Currently I have a the following way of retrieving data from my DB: $school->get('studentCount'); I required a shortcut to access these fields within the page and so came up with a format like this: <p>Blah blah blah [[studentCount]]</p> I have output buffering turned on but just need an easy way of replacing that key ('[[field-nam...

The best php basic framework

I'm wondering if there's any framework that I could use for basic website with cms features. Some features that I was looking for in the framework is, basic cms editing features, possibly easy way of constructing web forms, (contact us, feedback, subscription) pretty url with mod-rewrite. May be I'm asking too much. ...