php

How to scrape data from LocService (http://www.trackdroid.org/locservice.html) using PHP

Hi all. I'm looking to scrape geolocation data from LocService (a solution to track GPS pings from an Android phone) and host it in a MySQL database as a PHP cron job. The login system uses HTTPS. I'm having trouble returning anything through cURL. Has anyone got any ideas? Gausie ...

PHP cast to integer with only 1 or 2 chars

Hello. How can I cast to integer in PHP using only 1 or two chars? If I have the operation $a = (int) $b; it will result using those two (or one) chars: $a = <insert the needed 1 or 2 chars> $b; I need only to cast to integer. Thank you. ...

mysql vs ini files?

My php program is broken up into modules and each module has its own settings. These settings will hardly change, so would it be better to put the settings in a ini file or in a mysql database? If I go with the ini style then how hard is it to update the ini file? ...

$_SESSION['userid'] works in one function and not the next

Hi. I can't understand why this don't work. First i have a function like this where the user name shows up: if(isset($_POST['Commit'])){ if(empty($_POST['crime'])){ echo "You didn't select the type of crime you wish to do."; }else{ (...lots of code) $name = $_SESSION['username'];` Then I have another function where the username ...

Singleton failure. Initiates another object in include_once(somescript.php)

Hello I'm using the PHP singleton from Wikipedia. The problem is the singleton has a method that loads and runs other PHP scripts via require once and when these script are run and implement the Class method get_shared_instance a new singleton is initiated. Why is this? And what is the work around? the singleton (in a basic form): cla...

How can I create a random, circular partner assignment?

I'm allowing users to register on my site for a 'game'; as is normal, they all receive unique IDs. At a given point in time, registration will cease. At that time, I would like to run code to assign partners, but not pairs. So, if I had the following: +--------+-------+ | user_id | partner | +--------+-------+ | 1 | | ...

Problem sorting array with decimal numbers

Hello I'm trying to sort a simple array which only contains a few decimal numbers. e.g: ( [0] => 0.05 [1] => 0.076 [2] => 0.092 ) using this: $stuff = sort ($comparison); However when I use the php sort, asort ect functions, instead of getting a sorted array, I get the number 1. Very confusing! Any help? ...

Function ereg_replace() is deprecated - How to clear this bug?

Hello, I have written following PHP code: $input="menu=1&type=0&"; print $input."<hr>".ereg_replace('/&/', ':::', $input); After running above code, it gives following warning, **Deprecated: Function ereg_replace() is deprecated** How can I resolve this warning. ...

Facebook post to wall using FBJS or PHP

Hi guys, I am trying to post a message to a users facebook wall using FBJS or the PHP SDK, the problem I have is that I authenticate the user on the index.php page, but a flash program is calling my post_to_wall.php script which should update the users wall, but this is not working, here is the code, require "facebook-php-sdk/src/facebo...

Entering 0 into a field registers as empty?

Here is my code: if (isset($_POST['addmonths'])){ if (!empty($_POST['months'])){ if (is_numeric($_POST['months'])){ $monthstoadd = $_POST['months']; if ($monthstoadd < 1){ mysql_query("UPDATE users SET months='lifetime' WHERE username='$lookupuser'"); echo "Successfully...

Simplifying multiple echos

I have a full list of timezones in a select menu like so: <option value="Pacific/Kosrae"> Pacific/Kosrae( +11:00 GMT ) </option> <option value="Pacific/Kwajalein"> Pacific/Kwajalein( +12:00 GMT ) </option> <option value="Pacific/Majuro"> Pacific/Majuro( +12:00 GMT ) </option> <option value="Pacific/Marquesas"> Pacific/Marquesas( -...

How could I create two levels of authentication for registration on my site?

I already have a simple registration system in place using php and mysql. It operates well enough. However, when people visit my site and register, I would like for them to register as part of a particular group. So, I was thinking that registration would happen like this: Visitor lands on index.php, clicks on "Group Registration" li...

PHP: find key position in multidimensional array

Possible Duplicate: PHP: get keys of independent arrays Hello. I have a multi-dimensional array. I want a function that finds the position of the given array key (all my array keys are strings) and then returns the position of the key as an array. E.g: $arr = array ( 'fruit' => array( 'apples' => array(), ...

setting a url as visited

hello, I have a <a href="my_redirect_page.php?link=mylink">my_text</a> link on my page, and the following line in my_redirect_page.php: header("Location: ".$mylink); but after the redirection, if I click on back in my browser, the "my_text" for the link does not appear as visited (in purple, instead of blue). How do I work arou...

CURL error (CURLOPT_FOLLOWLOCATION cannot be activated)

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/path/curl.php on line 594 I don't have access to php.ini. Can this be fixed without editing php.ini? ...

php script for break connections

hi i want to ask...how can i break the connection of user to internet used php script...... thanks ...

How to flush output after each `echo` call?

Hi all! I've a php script that only produces logs to the client. When I echo something, i wan't it to be transfered to client on-the-fly. (Because while the script is processing, the page is blank) I had already played arround with ob_start() and ob_flush(), but they didn't worked. What's the best solution? PS: it is a little dirty to ...

Flash calling a PHP function

Hi guys, is it possible to call a PHP function from flash and have it execute right away? If so how could I go about doing that, because I am trying to call a PHP function that will update a users facebook status, but thus far I have been unsuccessful, so I am kind of at the end f my rope. Any help would be appreciated, thanx! ...

PDO Prepared Statement does not UPDATE table

I am developing an ORM based on PDO, for tables that don't have unique ID fields, so when I update or delete, I need to compare to the previous values of the record, and LIMIT 1. When my query finally gets to the database and is executed with the parameters, everything is correct, as confirmed by the general query log, however, nothing ...

What is the best way to create XLS file in PHP

Hey Everyone, I am currently trying to figure out the best way to create a .xls file from PHP. It seems like to me that all I need to do is change the header content type to "application/vnd.ms-excel", and then output data in a comma separated format. Is this the best way to do this? Thanks for any help!Metropolis EDIT Would it be ba...