php

Should I use a PHP Framework? If so, which one?

Hi, Ive been researching into PHP frameworks. I am trying to understand the utility of these frameworks. For e.g. does facebook use a framework? I guess not. Also, say I am developing a product which I want to sell users. Now suppose a use a framework like Zend, then I am unnecessarily imposing restrictions of using PHP 5 only. A lot...

Has anyone willingly gone back to php?

This is not meant as a slam on php. I use it frequently. Just curious though, has anyone "moved on" from php to use ruby or python as their primary scripting language, then "come back" to using php? ...

Zend_Rest_Client - error on localhost

Hi everybody, I am using Zend_Rest_Client to connect Zend_Rest_Server, everything seems to be allright, but when I try to get() from the server I recieve this error: Zend_Http_Client_Adapter_Exception: Unable to Connect to tcp://localhost:80. Error #10060: A connection attempt failed because the connected party did not proper...

javascript equivalent of php's preg_replace

I am using a simple regex to replace break tags with newlines: br_regex = /<br>/; input_content = input_content.replace(br_regex, "\n"); This only replaces the first instance of a break tag, but I need to replace all. preg_match_all() would do the trick in php, but I'd like to know the javascript equivalent. Thanks! ...

How can I make a radio button for "Other - please specify?"

I am creating an HTML form with some radio button options. I'd like to have one option as "Other - please specify" and allow the user to type something in. Two questions: 1) How can I make a "hybrid" input type of radio/text? 2) On the PHP back end, if the input has the same name attribute as the radio inputs, will the user's ...

Zend Error

Hello, How i insert my username, Password values to database using Zend framework. And how i get the values from the database using zend framework. Help me................................... ...

How do I send up debian sendmail to use google Apps smtp to by pass ISP blocking smtp

I have a debian webserver and it is running shopsite and some php programs. Which use sendmail to send out email to customers. So this server only needs to send email out. So how do I setup sendmail to use Google Apps smtp? Because I am getting the following error: sm-mta stat=Deferred: Connection reset by mx4.hotmail.com ...

Implementing keyword comparison scheme (reverse search)

I have a constantly growing database of keywords. I need to parse incoming text inputs (articles, feeds etc) and find which keywords from the database are present in the text. The database of keywords is much larger than the text. Since the database is constantly growing (users add more and more keywords to watch for), I figure the bes...

Reference counting in PHP

I'd like to implement database caching functionality in PHP based on reference counts. For example, code to access the record in table foo with an ID of 1 might look like: $fooRecord = $fooTable->getRecord(1); The first time this is called, $fooTable fetches the appropriate record from the database, stores it in an internal cache, an...

Calculating distance between zip codes in PHP

I grabbed a database of the zip codes and their langitudes/latitudes, etc from this This page. It has got the following fields: ZIP, LATITUDE, LONGITUDE, CITY, STATE, COUNTY, ZIP_CLASS The data was in a text file but I inserted it into a MySQL table. My question now is, how can i utilise the fields above to calculate the distance ...

Fastest way to implode an associative array with keys

I'm looking for a fast way to turn an associative array in to a string. Typical structure would be like a URL query string but with customizable separators so I can use '&amp;' for xhtml links or '&' otherwise. My first inclination is to use foreach but since my method could be called many times in one request I fear it might be too slo...

Selling "downloadable" content - handling behind the scenes

I was thinking of throwing together a quick PHP or Django site for independently selling some "downloadable" content (music/mp3's) to which I am the artist/rights-holder. I began to wonder if there are already some decent best-practices on how to handle the downloads - like how long a link should last for a user, the process of allowin...

Finding a dealer area via google maps API

I have a national customer who are currently recruiting dealers by selling each dealer an area for a set fee. They want a 'find a dealer' feature on their website which should point customers to the dealer who has purchased the area the visitor enters. At first we were going to list major cities with the hope that the visitor would cli...

Easy way to test a URL for 404 in PHP?

I'm teaching myself some basic scraping and I've found that sometimes the URL's that I feed into my code return 404, which gums up all the rest of my code. So I need a test at the top of the code to check if the URL returns 404 or not. This would seem like a pretty straightfoward task, but Google's not giving me any answers. I worry I...

Retrieving saved checkboxes' name and values from database

I have a form with checkboxes, each one has a value. When the registered user select any checkbox the value is incremented (the summation) and then then registred user save his selection of checkbox if he satisfied with the result of summation into database all this work fine ...i want to enable the registred user to view his selecti...

Connecting to an SQL Server mdf file via PHP

I currently have a school assignment that involves both PHP and asp.net. Now the assignment is that I make an E-commerce website with PHP and it's CMS with asp.net. Therefore both websites connect to the same database which is in SQL Server. At the moment using Visual Studio's SQL Server Express, and I have generated an mdf file as the ...

Best function to use when grabbing a body content

What is the best function to use in php when grabbing the contents of a file. Currently Im using fopen but when I try to get the headers it uses roughly 2-3 seconds to get the headers. Would HTTPRequest be a better option? ...

datetime vs timestamp?

What would you recommend using between a datetime and a timestamp field, and why? (using mysql). I'm working with php on the server side. ...

MySQL Simple Forum

So I'm trying to build a simple forum. It'll be a list of topics in descending order by the date of either the topic (if no replies) or latest reply. Here's the DB structure: forum_topic id, name, email, body, date forum_reply id, email, body, date, topic_id The forum itself will consist of an HTML table with the following h...

$_POST vs. $_SERVER['REQUEST_METHOD'] == 'POST'

Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST) Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue? ...