php

Storing and accessing a snippet of code in a function

Silly question, bare with me (I'm new). In my includes folder I have a function... function storelistingUno() { $itemnum=mysql_real_escape_string($_POST['itemnum']); $msrp=mysql_real_escape_string($_POST['msrp']); $edprice=mysql_real_escape_string($_POST['edprice']); //This value has to be the same as in the HTML form file $itemtype=m...

httpd.conf virtual host not working

I've added this: <VirtualHost *:8888> ServerName dietron DocumentRoot /Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/htdocs <Directory /Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/htdocs> AllowOverride All Options All </Directory> php_value inclu...

Merging and Adding data with SQLite

I am writing a PHP script that runs on a cron and pulls JSON data from an API [ title (text), path (text), visitors (integer) ] and stores it in a SQLite database. Every time it runs, if it sees an existing title, it should add the new visitors count to the existing visitors. If not, it should add the new data as a new row. Here's a sim...

Using an array as the key to a second array in Smarty (PHP)

I have two loops running in my code, I want to use an element from an array as the key in a second array, but am unsure how to do this with Smarty. "$dateAndUserForEdit.$key.edit_id" contains an integer (pulled from the db) I want to use that value as the key in a second loop, which runs fine if I harcode in the integer: {foreach from...

Generic "Killed" error in PHP CRON job

I am working on a CRON job in PHP which has to do a lot of heavy lifting via the database. Think lots and lots of loops. It executes properly when I limit the data set, but when I run it against the full data set, the script errors out with a simple "Killed" message. set_time_limit is (0) and memory_limit is (-1) Here is the code s...

How can I easily convert dates from UTC via PHP?

I am storing dates in a MySQL database in datetime fields in UTC. I'm using PHP, and I've called date_timezone_set('UTC') so that all calls to date() (without timestamp) return the date in UTC. I then have it so a given web site can select its timezone. Now I want dates to display in the site's timezone. So, if I have a date stored as '...

fixing cakephp .htaccess/mod_rewrite for shared hosting setups

I'm trying to install cakePHP on a shared hosting setup. After extracting the files to a location like ~/public_html/dev/cake and visiting the appropriate URL (in this case http://hostname/~username/dev/cake/), I receive a 404 error: Not Found The requested URL /usr/home/username/public_html/dev/cake/app/webroot/ was not found on thi...

Regex help, greedy vs. non-greedy

Hey all I have a large html string like <a style="background: rgb(100, 101, 43) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-backg round-inline-policy: -moz-initial;" href="#">swatch4</a> <a style="background: rgb(34, 68, 33) none repeat scroll 0% 0%; -moz-background-clip...

php studio

Hello fellow programmers. Is there any PHP "studio" like MS VS2008. By that I mean, in VS2005 you NEEDED to install IIS in order to run web applications in your computer, VS2008 creates a temporary mini server, so you don't HAVE to install IIS anymore in order to compile / debug in your computer. Anyway, I'm looking for something like t...

Connecting remote PHP/Apache server to Quickbooks/Windows

We have a Linux box with Apache, running PHP. We have a regular Desktop computer in the network running Quickbooks Enterprise Edition 9.0. I am trying to build a custom web application hosted on the Linux box that would be able to talk to Quickbooks. I'm new to Quickbooks, which makes it hard for me. While looking around I found many t...

Nice PHP algorithm to convert 120000000 into '120 mil' ?

I've been struggling to find a nice algorithm to change a number (could be a float or integer) into a nicely formated human readable number showing the units as a string. For example: 100500000 -> '100.5 Mil' 200400 -> '200.4 K' 143000000 -> '143 Mil' 52000000000 -> '52 Bil' etc, you get the idea. Any pointers? ...

Connecting to WS-Security protected Web Service with PHP

I am trying to connect to a Web Service which is password protected and the url is https. I can't figure out how to authenticate before the script makes a request. It seems like it makes a request as soon as I define the service. For instance, if I put in: $client = new SoapClient("https://example.com/WSDL/nameofservice", array('...

Lightweight, PHP based, layout framework...know of any?

I'm looking for a lightweight, PHP based, layout framework. Like how the Zend Framework, uses layouts, I would like to create a layout template and include only the content for the necessary pages. <html> <head> <title><?= $pageTitle ?></title> </head> <body> <?= $content ?> </body> </html> Anyone know of anything that does this? I wo...

Disabling Browser's "save password" feature on auth failure

I'm looking for a server-side implementation to disable a browser from saving invalid login credentials. For example, user "foo" logs in with password "bar". Browser asks foo if he wants to save the password. However, foo's password is actually "baz" and therefor would be saving the incorrect password. I've tried manipulating the HTTP c...

How do I perform a case insensitive search for a node in PHP xpath?

I don't want a search for the string value to be case insensitive. I want to do a search for the node without regard for case sensitivity. If the XML looks like this: <items> <ITEM>My text!</ITEM> </items> I need something like this to work: $someXmlDoc->xpath("/items/item/text()"); Currently, only this works: $someXmlDoc->xpat...

PHP Zip 3 small text files and force download

My website writes 3 small text files based on users information and then presents these 3 files as links that they must "right click" and save to their desktop. I would like to keep that, but also somehow offer a way to zip these 3 small files up and force download. And I don't want to save the zip file on the server either. Can this ...

PHP 2d Array Declaration

I am trying to define a 2d array in php. I have some concept code so you can see the situation: class Testing { protected $requiredFieldsByReferenceType = array( ['Book']['volume'] => true, ['Book']['source'] => true, ['Book Section']['volume'] => true, ['Book Section']['source'] ...

How to do a friends refererred and rewards system in php?

Hi, as title said, how to do or what are the practices to do a system, that if the user refer to a friends (up to 10), he will get rewards per person in php and mysql? Do I need to do in cookies or database? What are the required columns if using database? How to send multiple emails? ...

How to send mail via PHP and/or CakePHP on a Fasthosts account.

I've had no need to send mails on my 2 sites hosted at the UK Fasthosts provider. But since I've added some email features to one of my sites I've tried to send mail via the Email Component of CakePHP and it doesn't leave the server, even if the send returns success. I've tried with plain mail() function and with the smtp option and got...

how big is the performance impact of using system('hostname') in PHP?

I saw some existing code in the PHP scripts doing a system('hostname'); how big can the performance impact on the server be if using this method? ...