php

php multi-dimensional array remove duplicate

Not sure if this question is a duplicate in need of removal, but I couldn't find the answer elsewhere so I'll have a go at asking. I've got a 2d array that looks as follows: Array ( [0] => Array ( [0] => dave [1] => jones [2] => [email protected] ) [1] => Array ( [0] => john [1] => jones ...

Another tricky preg_match

Just need to see if a paragraph contains a "stop word", the stop words are in an array below. I had the formula as: $pattern_array = array("preheat", "minutes", "stir", "heat", "put", "beat", "bowl", "pan"); foreach ($pattern_array as $pattern) { if (preg_match('/'.$pattern.')/i', $paragraph)) { $stopwords = 1; ...

Alternative to returning mixed errors and booleans.

I have a (common) situation where I am currently returning a result that is a mixed type, sometimes a boolean, sometimes an error message. For example: function checked_thing_is_legal(){ // Do stuff and check for errors in here. } // Returns true if there are no errors, otherwise returns an error message string. This feels dirty, an...

PHP and mod_dbd

Does anyone know a PHP extension to use mod_dbd for database connections? Our application needs to access a remote database. It used to be an Apache module using mod_dbd for database connections and the transaction takes about 200ms. Now we changed the application to PHP and the same transaction takes over 600ms now. We hope some kind o...

One page website with CodeIgniter and jQuery(AJAX)

Hello, I am looking to build a one page website, that runs on PHP(obviously using codeigniter) and AJAX(supported by jquery), at the moment I have a menu that gets populated from the database, depening on what catergories are selected as being on line, the then build a an url using those results, if(isset($main_menu)) { foreac...

PHP Clean Up Permutated Array

Hey all, basically, i have an array: array('a', 'b', 'c'); Now i run it through an array permutation function and the result is: Array ( [0] => Array ( [0] => C ) [1] => Array ( [0] => B ) [2] => Array ( [0] => B [1] => C ) ...

PHP MYSQL file contents escape problem

Hi guys and girls, I am attempting to upload a .pdf file into a mysql database using php. It is all good except for the contents of the file. No matter how I seem try to escape special characters, the query always fails, mostly with "Unknown Command \n". I have used addslashes, mysql_real_escape_string, removeslashes etc. Does anyone...

How to set url parameters in an array?

Hey guys I am using open id authentication on my website and after authenticating I am getting a url from openid providers i.e yahoo and google http://www.mysite.com/openid-login.php? openid.identity=https://me.yahoo.com/a/1234567& openid.ax.value.nickname=john& [email protected]& http://www.mysite.com/openid-...

how to populate the second drop down using the selected value in first drop down?

Say I have two drop downs which are populated when the my jsp loads <select id="Group" name="group"> -- first drop down <option value="0001">1</option> <option value="0002">2</option> </select> <select id="subGroup" name="class"> -- second drop down <option value="0001-000">A</option> -- sub group associated with option ...

How can if find the size of a file prior to upload, with the help of jquery ?

I want to check the file size before uploading it, so that i can restrict the users before uploading. I want it use the jquery, but please suggest some thing else, if it is not possible in that way. I am using PHP at backend. ...

is there free or cheap software that formats PHP source code nicely

I am looking for a program, free or cheap, that formats the PHP code nicely. Sometimes I do copy and paste and the formatting looks screwed up. I found online source formatting but I would like to have a standalone program or an extension in my Dreamweaver (Windows) as it would be nice if I could apply source code formatting for all my P...

PHP uppercase to lowercase rewrite optimization?

I am using this PHP code to redirect any form of UPPERCASE in URI's to lowercase. There are three exceptions: if the URI includes either "adminpanel" or "search" there is no redirect, also if it already is lowercase there is no redirect Do you see any way to improve the function in PHP? $trailed = $_SERVER['REQUEST_URI']; $pos1 = strpo...

PHP errors are not displaying on the page you are developing. You only have SFTP Access to change files. How do you display the errors?

PHP errors are not displaying on the page you are developing. You only have SFTP Access to change files. How do you display the errors? ...

login to multiple web sites by login only once at a my site.

I want to create a site in php such that, when user would login to my website, then they can add their favorite website and enter its login information once. My site will save his login information for other sites in my database, and the next time, user logged onto my website need not to enter his login information to other sides again. ...

open_basedir error preventing avatar uploads

I'm getting this error when avatars are being uploaded on my site. I've changed "open_basedir = /home/" to "open_basedir =" in my php.ini on my server. It's a dedicated server and I rebooted it after making the adjustment. Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/) is not within the allo...

Need multiple independent timers in Ajax

I need the ability to create up to N amount timers in JavaScript/Ajax that will count like a stopwatch(but have no buttons). Another issue is that my data will be loaded via another Ajax request so the page will constantly be updating. I'm not sure how I would be able to keep a timer's correct value when that happens. Thanks! ...

What is the best way to implement strong security standards for $_GET id's?

I am seeking the strongest security measure for people changing the IDs in the URL for comments, blogs, inbox etc... Any suggestions? ...

Compressing content with PHP ob_start() vs Apache Deflate/Gzip?

Most sites want to compress their content to save on bandwidth. However, When it comes to apache servers running PHP there are two ways to do it - with PHP or with apache. So which one is faster or easier on your server? For example, in PHP I run the following function at the start of my pages to enable it: /** * Gzip compress page o...

SMTP protocol issue with Zend_Mail

I'm trying to send some emails via GMail SMTP and the CC and BCC lines are not receiving the email. I've tested GMail SMTP with Evolution (Linux email client), which works fine, though I could not get a raw dump of the communication because it's via SSL. Here's the communication log from Zend_Mail: 220 mx.google.com ESMTP 22sm2669783yx...

How to make Ruby AES-256-CBC and PHP MCRYPT_RIJNDAEL_128 play well together

I'm generating data to send from a Ruby stack to a PHP stack. I'm using the OpenSSL::Cipher library on the Ruby side and the 'mcrypt' library in PHP. When I encrypt using 'aes-256-cbc' (256-bit block size) in Ruby I need to use MCRYPT_RIJNDAEL_128 (128-bit block size) in PHP to decrypt it. I suspect the Ruby code that is broken, becau...