php

building ranking system with data from the database

I am building a ranking system that takes data(totals) from the database and ranks them from the highest to the lowest.Here is the code: $data = array( 'A'=>19,'B'=>18,'C'=>17,'D'=>17,'E'=>16,'F'=>15 ); //Populate the arrays with data from mysql /* -- -- Table structure for table `data` -- CREATE TABLE IF NOT EXISTS `data` ( `id` i...

Arithmetic Operations in Arrays with PHP

I have two arrays $data1 = array() $data1 = array( '10','22','30') and also another array carries $data2 = array() $data2 = array( '2','11','3'); I need to divide these two arrays(ie,$data1/$data2) and store value to $data3[]. I need to get it as follows $data3[] = array('5','2','10') If someone knows of an easy way to do this ...

downloading security related problem in php

hi i have to upload a video.but i want to gives permission only authenticate user to download .but i have a problem in that.because if any body type the video detail in browser.(ex http://sitename/folder_name/videoname) then browser download that video.but i don't want this .please suggest me how can i resolve this problem.either i shoul...

I want to extract the video link out of youtube embed code, I am searching for a regex solution for this

For example: an youtube embed code <object width="480" height="385"> <param name="movie" value="http://www.youtube.com/v/TFlzeO267qY&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt; <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://...

mysql query optimisation

i have around (1,049,906 total, Query took 0.0005 sec) in my x table , If i simply retrieve trying to retrive the particular field records , Its tooks hardly 6 mins , This is my query SELECT CUSTOMER_CODE FROM X_TBL ; CUSTOMER_CODE => UNIQUE THE ABOVE QUERY TOOK 6MIN , Tel me optimization tips for this , Also in some situatio...

memory leak in Zend_Db_Table_Row?

This is the code I have: <?php $start = memory_get_usage(); $table = new Zend_Db_Table('user'); for ($i = 0; $i < 5; $i++) { $row = $table->createRow(); $row->name = 'Test ' . $i; $row->save(); unset($row); echo (memory_get_usage() - $start) . "\n"; } This is what I see: 90664 93384 96056 98728 101400 Isn't it a memory le...

how to download and configure phpimage for TinyMCE

Actually I am looking for the best HTML editor for my CMS. With support for PHP and jQuery. I found TinyMCE but it doesn't have image upload functionality. Then I found phpimage, but every time I go to http://sourceforge.net/tracker/?func=detail&amp;aid=2844769&amp;group_id=103281&amp;atid=738747 and click on "files", I get the normal T...

dynamic meta data and description for pages

Hi, I am developing pages in php dynamically i.e data gets filled up from mysql DB. how do i assign a proper meta data and description for these dynamic pages so that google recognises it properly. What needs to be passed in page so that google takes description properly. when i search a page in google. it takes the data in page as des...

php code execution time

Hi How to find my code execution time , Am using the below snippet, am not happy with that ? list ($msec, $sec) = explode(' ', microtime()); $microtime = (float)$msec + (float)$sec; Regards ...

PHP miniwebsever file download

$httpsock = @socket_create_listen("9090"); if (!$httpsock) { print "Socket creation failed!\n"; exit; } while (1) { $client = socket_accept($httpsock); $input = trim(socket_read ($client, 4096)); $input = explode(" ", $input); $input = $input[1]; $fileinfo = pathinfo($input); switch ($fileinfo[...

step-by-step instructions for installing IMAGEMAGICK on WAMP?

This has been driving me mental, for hours and hours now.. There don't seem to be any concise tutorials/walk throughs for installing ImageMagick on WAMP for use with PHP. I've tried dozens of combinations of their binary releases with different php extension dll files. I can get imagemagick working fine from the command line and i can ...

Validate decimal number in (known) national format

PHP has many built-in functions to validate numbers but they all expect input in computer format: 1234.56. I need to validate stuff like 1,234.56 (English) or 1.234,56 (Spanish), together with some typical attributes (accepted range, max number of decimals, etc.). I started writing my own function but I soon got lost. It's easy to read ...

How to validate that a specific ammount of checkboxes are checked in PHP

I have to validate that maximum 3 checkboxes are clicked. There are 11. How could I do this efficiently and without testing every possible situation? ...

How do I include a file in a class?

Hey, I want to include a file to be accessible to any method/function in a PHP class. The file just contains a base-64 encoded variable. How do I do this? Thanks. ...

CakePHP ACO based on each entry

I'm trying to make a blogging system but obviously certain users in certain groups should only be able to edit/delete their own posts/comments. How would I go about doing this in CakePHP? I followed the manual's basic Acl guide to setup my current Auth system. ...

php sort properties of object

I want to sort the properties of an object so I can loop through them in a defined order. for example: I have an object 'book' with the following properties: 'id', 'title', 'author', 'date'. Now i want to loop through these properties like this: foreach($book as $prop=>$val) //do something now the order of the loop has to be 'title...

User Getting Logged Out After Making First Comment

Hello, I am using a login system that works well. I am also using a comment system. The comment function does not show up unless the user is logged in (as shown in commentformonoff.php below). When a user makes a comment, the info is passed from the function "show_commentbox" to the file comments2a.php. Then, the info is passed to t...

How to Integrate Uber Uploader in PHP project in windows server?

i ahave a form in which i need to upload the files of 50 mb, for which I want to use Uber uploader as it supports upload more than 10mb , but I am unaware of how to integrate the uber uploader in my project.. I am new to this and PECL and APC things used in project, I also cam to know that it needs linux server, which my client dont have...

$_SERVER['HTTP_REFERER'] vs Request.ServerVariables("HTTP_REFERER")

Why $_SERVER['HTTP_REFERER'] (PHP) and Request.ServerVariables("HTTP_REFERER") (ASP) return different result if query string has non english characters? php return correct value but asp will not: php: сабака asp: ׁ׀°׀±׀°׀÷׀° ...

Problem creating folder?

I am trying to create folder like this $destination = "../enumesis.com/_pcode/../_compile"; mkdir($destination); But this gives error UPDATE What i am doing is, taking ../enumesis.com/_pcode as input from user and I want to create a folder outside the _pcode Directory Here is my error Warning: mkdir() [function.mkdir]: No such file...