php

Communication between browsers via PHP

I am building a simple ajax chat client for a school project and have thought of a way to implement this, but it seems IMO to be very cumbersome approach: 1) User A sends message which is accepted by a server-side PHP script and saved to database 2) The browser of User B periodically launches a server side PHP script to check if there a...

OOP design: How to incorporate DB handling into application objects

This is a design problem I face regularly and I'd like to find some general insights about the subject. The code provided here is just an example. In the design phase it's easy to decide you need an object: User ========== Unique ID Login name Password Full name And it's easy to convert it into a database object: CREATE TABLE user (...

How can I keep a value in a text input after a submit occurs?

Hi there! I want to validate a form to make sure a user writes in a name and last name. If a user writes in only his last name, the form should show again with an error message beside the last name field, but the name value should still be there. I don't know how to do this, hehe. I'm just a newbie PHP programmer. Here's what I have ...

Will PHP DateInterval support decimals to add to a date/time?

According to wikipedia - en.wikipedia.org/wiki/ISO_8601 , it should be possible to do this (assuming PHP supports the full ISO 8601): $date = new DateTime(date('Y-m-d H:i:s', time())); // current time - create date time object date_add($date, new DateInterval("PT".round(2.5,2)."H")); //add 2.5 hours (throws exception unknown or bad form...

Conditional Directory Index In Htaccess

This relates to the question in: http://stackoverflow.com/questions/1599717/conditional-directoryindex-in-htaccess The answer states that the following should work: SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner <IfDefine owner> DirectoryIndex index.html </IfDefine> <IfDefine !owner> DirectoryIndex index.php </IfDefine> I am not ...

php string function concat

$contents = "<?xml version='1.0' ?> <authed>1</authed> <book>read</book>"; im having a xml string like this i want to add all the elements inside root tag like this $contents = "<?xml version='1.0' ?> <root> <authed>1</authed> <book>read</book> </root>"; ...

How to propagate a current menu item flag upwards in a multidimensional array?

I have a menu being built via a multi-dimensional array. A current item is set by matching its url attribute with the current request. I want this value to bubble up to its parents, but I can't for the life of me get it working - I'm sure I've been close, but it's proving a bit tricky. Here's the array: Array ( [children] => Array ...

What are the biggest differences between fopen and curl ?

I am making a web application in PHP and want to read content from a other domain. For that i have to options fopen and curl but what are the differences like security / options etc.? and what is the best way to use and why ? does it matter if the url from the other domain is a http or https site ? ...

PHP Session Cookies fail with users changing IP

Hello, I have a login script for a small application that works by storing session cookies and checking them on each page to make sure the user is logged in. One of the two users who uses the system keeps getting logged out randomly. This appears to be down to the session cookie that shows then authenticated no longer being present. Aft...

php mysql compare long and lat, return ones under 10 miles

Hay i want to find the distance (in miles) between 2 locations using lat and long values, and check if they are within a 10 mile radius of each other. When a user logs in, their lat/long values are saved in a session $_SESSION['lat'] $_SESSION['long'] I have 2 functions This one works out the distance in miles and returns a rounded ...

what is the easiest way for opcode caching with PHP/Apache ?

I was thinking to use opcode caching for performance profit what is the easiest way for opcode caching with PHP/Apache ? and what are the performance improvements ? I have read about xDebug but I was wondering if there are more options ? ...

Why are some variables in PHP written in uppercase?

Why does some code in PHP have to be written in uppercase? For instance: if(isSet($_GET['lang'])) $lang = $_GET['lang']; $_SESSION['lang'] = $lang; Do they work if I write them in lowercase? ...

Calling a JAVA web service created using Axis from PHP code

Hello, Im trying to call a Java web service created using Axis from PHP code.The webservice is hosted on my LAN. I am able to call the web service successfully using SoapUI. I have the PHP Soap Extension installed. However,im not sure whether my PHP code is correct. Below is my PHP code. <?php $client = new SoapClient('http://machinen...

php how to preserve session state for prolonged period of time? troubles...

I'm having trouble preserving session state for a prolonged period of time. I use sessions to preserve login state. I require the below snippet of code at the top of each of my pages before any other code. First off, is there any settings I'm missing? session_cache_expire(2880); //set session to expire in 48 hours session_start(); So...

Equivalent of Mongrel/Webrick for PHP Development?

Hi all. Is there an equivalent in PHP development to using Mongrel/Webrick during Rails development? I normally use Mongrel on port 3000 to serve up my Rails app during development. Its been a couple of years since I've done PHP development. From what I recall, the method was to run Apache on the dev machine during PHP development (w...

Openx: delete all statistics

What tables shall I empty to delete all my statistics (openx 2.6.2)? (My maintenance.php can't run in 300s max execution time so, right now, I just to keep my zones, websites, etc and just prune all the stats) ...

AMFPHP Bad Version error when having multiple simultaneous calls to gateway.php

I'm currently using AMFPHP 1.9 to make a simple flash game which uses a game server. Sometimes, I get this error (BadVersion) when there are simultaneous calls to the server. I've searched the web for some of the answers to this problem, and it seems they were answered back in 2004. Is there an updated version of how to solve this pro...

someone to help with MYSQLI & Stored PRocedure

hey i want to make a search feature with mysql stored procedures and php. how can i do this? i know how to call proc but how to send "q" input to procedure? thank you ...

Check if Variable in array javascript

Short code for checking if a variable also exists inside an array is needed. Im thinking something like this: var category='cars'; if (in_array(category, some_array)){ do stuff! } Is there any such function in js? Thanks ...

PHP - write to first element of an array

How to write to the first element of an array? I know reset can return the first element... but you can not use it to write to it. ...