php

Calculating number of online visitors?

i need to show the number of online visitors, but there is a problem with selecting algoritm to do it! maybe i must create a table in DB, where i'll store ip addresses of visitors and time of visit! by so i can show the count of ip addresses, which's time >= NOW() - 10 minutes, for example...("now()-10 minutes" is just to show the logic,...

Using readfile() with remote URL and SSL

I have a php-based website that uses SSL and requires a a user to login before accessing any page. I would like to allow access to this site from another domain, so that the functionality remains the same, but the look, feel and domain changes for the user (with the added advantage that I have to maintain only one version of the code). ...

PHP numbers manipulation

$ch is a character. I need to convert it into 2 numbers like that (example): $ch = 'A' => ASCII code: 0x41 => Binary: 0100 0001 => {4, 1} What is the easiest and fastest method to achieve this ? ...

Getting error while connecting to facebook

I have downloaded php-sdk for using facebook in php. I also created facebook application in the facebook web page in order to get API key and secret key. When I run example.php and try to connect to facebook it shows me the following error: Configuration errors: To fix this error, please set your Connect URL in the application settings...

php: sort and count instances of words in a given string

Hello, I need help sorting and counting instances of the words in a string. Lets say I have a collection on words: happy beautiful happy lines pear gin happy lines rock happy lines pear How could I use php to count each instance of every word in the string and output it in a loop: There are $count instances of $word So that the ab...

error during page redirection

when I redirect my page to another page header("location:popup.php"); it gives following error - Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\303\levelupdate.php:289) in C:\xampp\htdocs\303\levelupdate.php on line 320 ...

mySQL: Joining three tables - how?

Hi everybody, I have the following query in my application. It works well, but I need it to also contain the number of products that are associated with each manufacturer. The current query: SELECT * FROM (`manufacturers`) JOIN `languages` ON `manufacturers`.`lang` = `languages`.`id` ORDER BY `languages`.`id` asc, `id` asc My prod...

preg_replace only replaces first occurrence then skips to next line

Got a problem where preg_replace only replaces the first match it finds then jumps to the next line and skips the remaining parts on the same line that I also want to be replaced. What I do is that I read a CSS file that sometimes have multiple "url(media/pic.gif)" on a row and replace "media/pic.gif" (the file is then saved as a copy w...

Include PHP file content as argument to function that expects string value?

Is it possible to include a file that contains a string value (in this case a comma delimited list of values) as an argument to a function? For example: include.php <?php 'value1,value2,value3' ?> function.php <?php function test($string) { echo $string; } test(include 'include.php'); ?> I've tried this and it doesn't work, ...

More readable SVN-diff in PHP

Hi, I'm using svn-diff function from PECL (http://www.php.net/manual/en/function.svn-diff.php). The output is not really easily readable. How do I change it to something more readable like winmerge's output, with color highlights, strike-through etc? Doesn't have to be using pecl SVN, any php solutions would do. Thank you! ...

WordPress 2.9.2 VS WordPress 3.0 Release Candidate

I'm going to do a new install of Wordpress. new 3.0 version is coming. current stable version is "WordPress 2.9.2" and "WordPress 3.0 Release Candidate" the last release before final version 3. So for now i should setup 2.9.2 or 3.0 Release Candidate? will i have to replace all files to RC upon final release? What are cons to use Rel...

How to insert PHP script into HTML the best way?

Hello, I have to insert full path to every single image/css file of my website, because of url_rewriting and I'm looking for the most officiant way to do it. Of course I could do: <img src='<?php echo $full_path; ?>/images/theImg.jpg' alt='alternative text' /> But somewhere I saw people doing it like this, or something: <img src='{...

HTTP New location after download starts

Hi I'm using X-Accel-Redirect (so implicitly nginx), Content-Type and Content-Disposition to download a file, everything works great. What I need to accomplish is redirecting to a new location after the download starts. I've tested with both Refresh and Location, it doesn't work. Is it possible with HTTP 1.1/nginx? Addendum I am loo...

technology for new webproject?

Hi there, i am planing to set up a new webproject which has to use a database and a model which can be presented in a browser. I looked at a lot of technologies (JSF, PHP, ..) but i could not find a free and easy framework/technology for me (in the end i prefered asp.net, but this is not free). What can you recommend me for a new webp...

php http pipeline

Hi! I'm trying to get timestamp on beginRequest and on endRequest when processing an http request using php. I know how to do it on asp.net (using httpModules and the finction beginRequest and endRequest). Does anyone know if this option is available on php and guide me how to do it? (I'm not looking for a solution, just some guiding or...

Leading zeroes in php

Hello, I would like to present a list from 0 to 59 of with the numbers 0 to 9 have a leading zero. This is my code but it doesn't work so far. Any idea's? for($i=0; $i<60; $i++){ if($i< 10){ sprintf("%0d",$i); } array_push($this->minutes,$i); } ...

Can I expose MySQL data using PHP and OData?

As I understand it, OData is just a standardized way to expose relational data RESTfully. If I've got a PHP application, it should be able to process those RESTful requests and manipulate a MySQL database based on the request data and then return an ATOM feed. First, are the preceeding statements correct? Second, does a PHP library to...

do you need captcha validation in newsletter subscription?

I am using a custom captcha php script along with news letter scripts to let users subscribe using an email id. The method of registration is based on jQuery.post command. My question is that am I really safe If I remove the captcha validation from my subscription script. The subscription is simple. For example mydomain/subscribe.php?e...

Unexpected $end in PHP file

I'm working on a PHP contact form, but I can't get it to work. I get the following error in the Apache server log, running on an Ubuntu Server VM: PHP Parse error: syntax error, unexpected $end in /home/matthew/Sites/contactFormResponse.php on line 75, referer: http://192.168.1.4/contactForm.php From googling this error, it sounds li...

Add link around img tags with regexp

I would like to add links around image tags with preg_replace(). Before: <img href="" src="" alt="" /> After: <a href="" ..><img href="" src="" alt="" /></a> I would greatly appreciate any help. Thank you very much. ...