php

PHP Print Date Variable Format

So this should be a real easy question but I can't seem to find a simple answer anywhere. I'm patching up some PHP code (I'm not a PHP'er) and I have this variable $orderDate. How do I print this variable so that its just M/d/yy h:mm tt? Update: So I looked around and saw what $orderDate is. Here's the code: global $orderDate; $orderD...

Installing PDO extension for MySQL on Mac OS X Server

I would like to keep the PHP / MySQL combo as 'stock vanilla' as possible but would like to install the PDO driver for MySQL. How can I do this on 10.5? ...

Add certain namespace to a SOAP Envelope in PHP

Hey ! I really need to add a certain namespace to a SOAP Envelope which is not specified in the WSDL for some reason I already tryed using the 'uri' parameter in the SoapCliente constructor but it's not working how can I add this namespace to the SoapEnvelope ? thanks in advance ...

Count with PDO

There are many conflicting statements around, what is the best way to row count using PDO in PHP with MySQL? Before using PDO I just simply used mysql_num_rows. FetchAll is something I won't want as I may sometimes be dealing with large datasets, so not good for my use. Any suggestions? ...

PHP include_once: handling of imports i.e. for configuration files

Let's assume we have the following structure: index.php config.inc.php \ lib \ lib \ common.php Several parameters like database name, user & co are configured in config.inc.php. What is the proper way to access them i.e. from a function located in \lib\common.php. Do I really have to do an include_once("config.inc.php") within each f...

Get form checkbox values and pass them through pagination?

Hello. I need to get values from selected checkboxe's and pass that values through pagination witch is done by php/mysql. And if on another page user select other checkboxes add their values to array of earlier seleced. I need this for product compare page. In short i get checkbox values store them add checkbox values from other pages ...

Ignoring PHP error, while still printing a custom error message

So: @fopen($file); Ignores any errors and continues fopen($file) or die("Unable to retrieve file"); Ignores error, kills program and prints a custom message Is there an easy way to ignore errors from a function, print a custom error message and not kill the program? ...

Can someone explain a little bit about caching dynamic PHP pages?

I was wondering about caching dynamic PHP pages. Is it really about pre-compiling the PHP code and storing it in byte-code? Something similar to Python's .pyc which is a more compiled and ready to execute version and so that if the system sees that the .pyc file is newer than the .py file, then it won't bother to re-compile to .py file. ...

Form generator and data capture PHP application

Hi, Does anyone know of a PHP open source which can generate forms to be deployed across your website. These forms will collect and aggregate the data with in on database. There should also be the functionality to search across the forms (to generate reports and newsletter mailing lists) All the services I have found so far have been...

what is the best way to load config files for different versions of the same project on the same server?

I have a large php project that relies on two levels of config files. In my project folder I have a default.config.ini that is loaded and then merged with a site specific config file. At the moment the code is reading an environment variable PROJECT_CONFIG that points to the specific config file. This works fine for each developer wor...

Best way to sanitise POST/GET variables from a form/URL?

I am creating a website using PHP that makes use of a MySQL database and handles forms and variables from the URL. The variables are being using to dynamically construct SQL query strings. So i need a robust solution to make sure nobody is trying a SQL injection, etc.. A friend of mine has said that really i should only use stored proced...

multilingual php script question

Hi folks. I have this PHP script. It's the only one that really worked to me: <?php /*Check_if_user_has_changed_language: */ if(isset($lang)){/*If_so:*/ setcookie("ling",$lang,time()-60*60*24*365,"/",".sayip.info",0);/*Wipe_previous_cookie*/ setcookie("ling",$lang,time()+60*60*24*365,"/",".sayip.info",0);/*Whatever_the_means_l...

Can Ruby, PHP, or Perl create a pre-compiled file for the code like Python?

For Python, it can create a pre-compiled version file.pyc so that the program can be run without interpreted again. Can Ruby, PHP, and Perl do that same on the command line? ...

RegEx in PHP: Matching a pattern outside of non-escaped quotes

I'm writing a method to lift certain data out of an SQL query string, and I need to regex match any word inside of curly braces ONLY when it appears outside of single-quotes. I also need it to factor in the possibility of escaped (preceded by backslash) quotes, as well as escaped backslashes. In the following examples, I need the regex...

Does rewriting a URL help a search engine find the page?

My URLs look like "/pages.php?page=pageName" because I am using a database to supply the page's content. Does rewriting URLs to something like "/pageName" help search engines find the pages? If so how do I rewrite them? ...

Using OpenID to prove Stackoverflow membership

Here's the deal: -Flair pretty much demands a Facebook app -I'm working on learning the Facebook platform Therefore, I've written a dinky little Facebook app to embed your Flair into a box on the side of your profile. If you're interested and on Facebook; beware that this is very much a work in progress, prone to change and has a whole...

can a developer be held responsible for a clients fradulent activity on a delivered website

If i delivered a website to a client and the client decides to do fraudulent activity with the website such as a e-commerce site would i in anyway be held accountable? this hasn't happened its just a question that was raised in my head :) ...

How do I use PHP CLI to automate FTP when I don't have access to PHP's native FTP handle?

I'm writing an automation script on a production server that, among other things, needs to grab a list of remote files via FTP (FTP is the only option for interacting with the remote filesystem) and selectively download them. Why I can't use PHP's native FTP wrappers This is a production server in a very brittle environment. I'm writi...

Sort and display directory list alphabetically using opendir() in php

Hi there, php noob here - I've cobbled together this script to display a list of images from a folder with opendir, but I can't work out how (or where) to sort the array alphabetically <?php // opens images folder if ($handle = opendir('Images')) { while (false !== ($file = readdir($handle))) { // strips files extensions $crap = ar...

Improve my function: generate SEO friendly title

I am using this function to generate SEO friendly titles, but I think it can be improved, anyone want to try? It does a few things: cleans common accented letters, check against a "forbidden" array, and check optionally against a database of titles in use. /** * Recursive function that generates a unique "this-is-the-title123" string ...