php

JavaScript Detection / Browser Statistics

This has been asked few times but I think it's still worth checking with you guys for some more input. All my websites use Google Analytics for stats. Since it relies on JavaScript I thought it was important for me to check how many people actually have JS enabled in their browsers enabled/disabled. I remember I usually checked w3schoo...

POST variable problem.

I'm having a really strange problem with this code I'm working on at the moment. It's a map editor for a game that sends the variables for each tile to another PHP file to update the mySQL database. So far the map editor code displays the map and loads everything fine. The map update (mupdate) PHP file correctly updates the database, if...

PHP Date Time Current Time Add Minutes

Simple question but this is killing my time. Any simple solution to add 30 minutes to current time in php with GMT+8? ...

Odd problem with loop

I have the following loop, which works fine if i<1 but gives me the the following error if i<2. I cannot for the life of me figure out what it is. I get this error: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 1244790000 - datec...

How do i determine the nth weekday of a given date in php

Hi, I am working on a calendar script where in i need to repeat a calendar event like "Repeat on every 1st Tuesday of every month" In the example above. How do you get the "1st"? for example today is June 12,2009 this would mean it's "2nd Friday of June" How do i get the "2nd"? Thanks in advance ...

save the file in users desktop

I have a file where i m able to generate the pdf, but i want the path to be users desktop which would save it automatically. $pdf->Output("sample.pdf"); What should be path. ...

how to set up a php mysql site quickly?

Hello, I am looking for ways to setup a basic site quickly. I have a basic site which works with a databasem, templates, css, js and so on. No I want to be able to quickly set up a site. What shoudld happen when i start the script is: ask for some variables on submit: create a folder in the webroot copy the standard site to that map ...

Yahoo Messenger API For PHP

Hi, I've asked the same question before for Flex, but due to some restrictions, I'm gonna have to do all the communication from the back end. I googled all day, I just can't find anything that works. Thanks, ...

consecutive <li> classes

I have trouble finding an expression to automatically generate a new 'class' like the following: <ul> <li class="img1">link</li> <li class="img2">link</li> <li class="img3">link etc...</li> </ul> This is nested in 2 tabs for 'most read' / 'latest comments'. The different classes are so that I can make a different bullet (number) usin...

Sanitize a PHP password string

I have a PHP page that allows people to run htpasswd to update their password. What is the best way to sanitize their input. I don't want to restrict the input to much because I want to allow for secure passwords. This is what I have. How can it be improved? $newPasswd = preg_replace('/[^a-z0-9~!()_+=[]{}<>.\\\/?:@#$%^&*]/is', '', $...

calling wcf /web service from php/ruby

For my sins, I am in charge of developing a service for providing data to both our internal systems running .net apps as well as external systems running php. For the sake of future proofing, I want to ensure it is callable from ruby as well. My service will perform authentication and look up account details from a central user reposit...

What would cause my MySQL query to hang after two results?

Hi, I have a simple query that I can't for the life of my get to print out on my page: $results = mysql_query("SELECT * FROM andyasks ORDER BY date"); $test = mysql_fetch_array($results, MYSQL_BOTH); foreach ($test as $row){ print($row[questions]); } What this outputs is (unpredictably, to my eyes) just the first letter of each ta...

How to extract the embedded attachment name from this email?

My regex skill is... bad. I have this email body. Hello World [cid:[email protected]] Hello World [cid:[email protected]] [cid:[email protected]] Hello World And what I need is an array of the filenames. preg_match_all("/\[cid:(.*)\@/", $string, $matches); echo "<pre>"; print_r($matches...

PHP fseek() equivalent for variables?

Hi, What I need is an equivalent for PHP's fseek() function. The function works on files, but I have a variable that contains binary data and I want to work on it. I know I could use substr(), but that would be lame - it's used for strings, not for binary data. Also, creating a file and then using fseek() is not what I am looking for ei...

Using search from other site on yours

I want to put a search form on my site, but when you hit search, it will search another site. For example, I have a form on mydomain.com/search that will search domain.com/search?term="keyword" Once I hit the search button, I want it to open a new window appending the keyword to the URL. Can this done via jQuery/PHP? ...

Referencing the next iteration before it happens in PHP

Hi, I have a table in MySQL with "text", "date_posted", and "user". I currently query all text from user=Andy, and call those questions. All of the other text fields from other users are answers to the most recent question. What I want is to associate those answers with the most recent question, with a loop similar to "for each text wh...

PHP5 Classes: inheriting a composed class?

Hey all, I'm trying to get the following to work, but I'm at a loss... class Foo { public $somethingelse; function __construct() { echo 'I am Foo'; } function composition() { $this->somethingelse = } } class Bar extends Foo { function __construct() { echo 'I am Bar, my parent is Foo'; } } c...

Spawn and detach PHP process without sharing any db-resources so that the child can exit?

I want an "eternal" process that goes through a MySQL table and spawns child processes. Pseudo code: while(true) $rows = SELECT * FROM workers foreach($rows as $row){ DELETE $row->id spawn_child($row->id) } sleep(5) } function spawn_child($id){ $pid = pcntl_fork() if($pid <0){ //err ...

Can someone explain me the pack() function in PHP?

Hi, I would like to know more about the pack() function in PHP: http://fi.php.net/manual/en/function.pack.php I know it packs data into binary, but I'm not sure what all those v V n N c C mean and I was wondering if someone could be kind and give me a practical demonstration when to use which formats? The online documentation, for cha...

Zend url view helper - keeping existing params in a reversed route

At the moment in my ZF project have a URL structure like this: /news/index/news_page/1/blog_page/2 When I generate my pagination I use the URL helper as follows: <?php echo $this->url(array('blog_page'=>3)); ?> Which generates a URL like this: /news/index/news_page/1/blog_page/3 What I'd like to do is use a custom route to have ...