php

SIP subscription in PHP

I have several Snom VoIP phones in the office running off a virtual phone system in London somewhere. I've written a small PHP app that lets me control the phone remotely - all it does in the background is cURL into my handset's web interface and control it that way. However now I'd like my PHP app to know what other phones on the syst...

Keep only 10 records per user

I run points system on my site so I need to keep logs of different action of my users into database. The problem is that I have too many users and keeping all the records permanently may cause server overload... I there a way to keep only 10 records per user and automatically delete older entries? Does mysql have some function for this? ...

Insert a +1 to the database table

Hello all, my WHERE do so my page dont work and i dont know how i do so then a user create a comment then a number in my thread will grow +1. i wanna do this because then i user create a new comment the users who follow that thread can see "oh there is a new comment to the topic o follow" here is my code if(isset($_POST['opret_kom...

Facebook Tab not loading

so i created a facebook app (fbml). canvas url = http://mydomain.com/fb/canvas/ tab url = tab.html i authenticated my app with my profile and added the tab to my profile. but the tab keeps loading and loading. sometimes i also get redirected to my profile page after a short tab loading time trying to access my canvas page http://a...

MongoDB MapReduce returning no data in PHP

Hi all, I'm using a Mongo MapReduce to perform a word-count operation on a bunch of documents. The documents are very simple (just an ID and a hash of words): { "_id" : 6714078, "words" : { "my" : 1, "cat" : 1, "john" : 1, "likes" : 1, "cakes" : 1 } } { "_id" : 6715298, "words" : { "jeremy" : 1, "kicked" : 1, "the" : 1, "ball" : 1 } } ...

Script to update your production DB from test DB

On my local computer I have a test environment running XAMPP. I am working on a PHP / MySQL application. Now I often make changes to the local website, but when I want to upload I have to do a lot of work. This is what I do now. I export my local DB trough phpMyAdmin I clear my remote DB I import the exported DB. Sometimes the DB is k...

What does "#include "myfile.php" do?

What's the meaning of the # symbol in the following line of php code: #include "myfile.php"; ...

How to get special char as a parameter from url

Hi guys I have a url like http://localhost.com/api/authenticateuser?user=demo&pass=demo#123 But when i use $_GET['pass'] i am only able to get value of $_GET['pass'] is "demo" not "demo#123" is there any way to get parameter value as "demo#123" Thanks ...

What are the problems/benefits of overloading an argument's type?

Often I write functions whose operation depends depends on the type of some argument. An example would be a function that would help me to insert rows into a mysql database. function insert($table, $columns, $values) { if(is_string($values)) { $values = "('" . $values . "')"; } else if(is_array($values)) { ...

Creating a custom function to replace one in WordPress

Hi Guys, I'm using WordPress 3.0 and the 'the_post_thumbnail' function to resize my images. The problem is that the function doesn't resize to exact dimensions when you don't specify a square image. // Works fine add_image_size('my-image-size',100, 100, true); // Image is only resized to width or height, not both add_image_size('my-i...

formated text in textarea

IF I have a string <b>This Is In Bold Letters</b> then how can I include in a <textarea> so that the string appears in BOLD letters? using javascript & php? Pls help dear friends ...

First project for resume

Which project is better to write the for job ( Developer PHP )and then not be ashamed to refer to on his resume? What functions should it feature ? If anyone has a ready, detailed terms of reference for similar Drafts, please point me in that direction, or if you have the opportunity, show a sample list of what to do in such projects. ...

Xpath php fetch links

I'm using this example to fetch links from a website : http://www.merchantos.com/makebeta/php/scraping-links-with-php/ $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); var_dump($href); $url = $href->getAttribute('href'); echo "<...

Security and throwing an Exception

Hi all. I wrote a function that gets the balance from PayPal. To connect properly I'm passing the user, password and certificate as parameters. Every thing looks ok until something throws an Exception inside and php prints all the parameters (user details in this case) on the stacktrace. I'm logging everything to a file so users wouldn'...

Accidentally ordered a PHP6 book for learning PHP

I want to learn PHP so I ordered a book about it called "PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide" I stumbled upon the php.net website and found out the latest thing released was PHP 5.3.2 The describtion of the book says that "[...] 20% or so of the material requires version 6 of PHP." DID I SCREW UP AND SHOULD...

polish characters utf8 dont show right

Currently my site supports English, portuguese, swedish and polish. But for some reason some polish characters dont show right, like Zal�z konto it should look like this Zalóz konto I have this // Send the Content-type header in case the web server is setup to send something else header('Content-type: text/html; charset=utf-8'); and ...

phpThumb - change watermark size

Hi guys, I'm using phpThumb in a script to clean my images and add a watermark to them. We have images of very different sizes (from 100px width to 800px), so no matter what watermark image I use, it's either going to look too small or too big on the image. Do you know of a way to tell phpThumb to resize the watermark? Or is there a ...

HTMLPurifier dies when the following code is run through it.

Using the latest release of HTMLPurifier with default configs. The following code will cause the oh-so-lovely blank white page in PHP. Am I missing something? Even if I set HTML.TidyLevel to light or none it still breaks. Here is a partial log of the errors thrown when trying to purify the code below: http://pastie.org/private/13f0htscq...

deleting cookies without leaving the browser !

HEY GUYS deleting cookie is a easy thing to do in php but problem is untill i get out of my browser it still exists setcookie("PHPSESSID", false); setcookie("PHPSESSID","",time()-31536000); any way to delete this cookie whithout need of closing the browser ?! so what do u think ?! ...

PHP: merge two arrays while keeping keys instead of reindexing?

how can i merge two arrays (one with string => value pairs and another with int => value pairs) while keeping the string/int keys? none of them will ever overlap (because one has only strings and the other has only integers). here is my current code (which doesn't work, because array_merge is reindexing the array with integer keys): //...