php

Web forwarding proxy in C# or PHP available?

I have some shared server web hosting in the States (I'm from the UK), which allows me to publish PHP and .NET applications. I cannot install my own software onto the remote server, but I'd like to set up a web forwarding proxy for accessing sites that serve different content depending on what country you're from. My C# and ASP.NET skil...

Trouble with PHP MySQL fetch array function

I have a database with 2 tables. One of the tables holds a row containing numbers, from 0 to 10. In PHP, I do this: $query = "SELECT ".$param." FROM issues WHERE ".$param." >=0"; $result = @mysql_query($query) or showError("query failed"); if (!($record = mysql_fetch_array($result))) return null; return $record; The $param holds t...

Can I have multiple php.ini files?

I want to set the include_path variable in my php.ini file. (C:\Windows\php.ini) But, I want different include_path values for different sites hosted on the same Windows server. How can I do this? ...

PHP new operator returning reference

I'm working with some old PHP code that has a lot of the following: $someVar =& new SomeClass(); Did the new operator ever return a value, um, not by reference? (That feels strange to type. I feel like I'm losing my mind.) ...

php: pushing to an array that may or may not exist

I want to create an array with a message. $myArray = array('my message'); But using this code, myArray will get overwritten if it already existed. If I use array_push, it has to already exist. $myArray = array(); // <-- has to be declared first. array_push($myArray, 'my message'); Otherwise, it will bink. Is there a way to make...

google sitemap - should I provision for load control / caching?

I have a community site which has around 10,000 listings at the moment. I am adopting a new url strategy something like example.com/products/category/some-product-name As part of strategy, I am implementing a site map. Google already has a good index of my site, but the URLs will change. I use a php framework which accesses the DB for...

Enumeration management with zend framework (ZF)?

Is there any existing project or incubator to manage user administratable lists of options? We have several 100 lists (most populate dropdowns in our application), many are quite short < 50 items, several with a few hundred items and a handful with thousands (<30,000) entries. What we are looking for is a database based structure and UI...

How abstracted should MVC models be?

I'm in the process of extending and improving a website that has quite a few structural problems. It looks very much like the developers before me had heard of MVC but didn't understand the ideas of abstraction or modularity. So the MVC "framework" is a) bespoke b) broken c) patched and d) there are several in use all at once. I intend t...

Can you call one Drupal views template for multiple views?

I've used the Views Theming Wizard to output a template and it gave me the following chunk of code to go in template.php. I'd prefer to just maintain the one template, so all my functions will be calling the same one, and rather than writing numerous versions of the same function, I'm wondering if there's a way to string function names ...

How to Build a Secure Send-to-a-Friend Function in PHP?

Can anyone suggest a way, or a link to an example, of building a function in PHP that allows users to send a link via e-mail to multiple friends? ...

Call to a member function xpath() on a non-object?

I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function xpath() on a non-object. Below are the lines I'm trying to use to get the image's source tag: $xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img'; $html = new DOMDocument()...

PHP simplexml: why does xpath stop working?

A strange thing happened after a supplier changed the XML header a bit. I used to be able to read stuff using xpath, but now I can't even get a reply with $xml->xpath('/'); They changed it from this... <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE NewsML SYSTEM "http://www.newsml.org/dl.php?fn=NewsML/1.2/specification/NewsML_...

Kohana events, where to place them

I'm trying to understand the event system of Kohana. The only thing i don't understand is, where to place the Event::add code. It should be in a place where it is executed before any events are fired. Or am I missing something? What i want to achieve is to construct a class that is available everywhere, but don't realy want to hack i...

Base conversion of arbitrary sized numbers (PHP)

I have a long "binary string" like the output of PHPs pack funtion. How can I convert this value to base62 (0-9a-zA-Z)? The built in maths functions overflow with such long inputs, and BCmath doesn't have a base_convert function, or anything that specific. I would also need a matching "pack base62" function. ...

php and sql query failing

Hello, I have this code http://www.nomorepasting.com/getpaste.php?pasteid=22580 which is part of a small ajax application. I would like to know a better, more efficient way to assign $query, instead of copying the sql each time with a different query or a bunch of if clauses. Basically the query will be dependant on the link clicked...

PHP Flush: How Often and Best Practises

I just finished reading this post: http://developer.yahoo.com/performance/rules.html#flush and have already implemented a flush after the top portion of my page loads (head, css, top banner/search/nav). Is there any performance hit in flushing? Is there such a thing as doing it too often? What are the best practices? If I am going to h...

converting unicode for mysql and JSON

Hello, I have some html that was inserted into a mysql database from a csv file, which in turn was exported from an access mdb file. The mdb file was exported as Unicode, and indeed is unocode. I am however unsure as what encoding the mysql database has. When I try to echo out html stored in a field however, there is no unicode. This i...

JQuery $.ajax "async: false" bug?

Hi, I would appreciate your opinion/advice on the following Scenario HTML has PDF file nick name, back end has URL for each nick. The link URL is always download.php?what=%PDF_Nick% to ensure download for JS disabled clients. For JS enabled clients I do JQuery AJAX call and rewrite link URL from download.php?what=%PDF_Nick% to ht...

Search in a mysqldb with php

How to implement a great search within a mysqldb - within a table if i search with '...LIke %bla%....' not all entrys would be found - if bla within a word for example. a search with soundex would be great to - but if i read the manual i must create an soundex-index to search for soundex-values? So the question whats the "best practice...

How to get multiple parameters with same name from a URL in PHP

I have a PHP application that will on occasion have to handle URLs where more than one parameter in the URL will have the same name. Is there an easy way to retrieve all the values for a given key? PHP $_GET returns only the last value. To make this concrete, my application is an OpenURL resolver, and may get URL parameters like this: ...