php

keep params and add another from a form

Hey Guys, I have the following 3 urls: http://www.test.com?a=1 http://www.test.com?a=1&amp;b=3 http://www.test.com?a=1&amp;b=2&amp;c=99 Now in a form i have a drop down menu like so: <select name="b"> <option value="1">1</option> ... </select> Now i want to either add that param to the list of existing params or edit th...

how to sort a multidemensional array by an inner key

i have this enormous array that i am pulling from an API for BattleField Bad Company 2, and the soldier stats can be pulled as a multi dimensional array with an inner array for each soldier, however the API sormats it sorting the soldiers by name alphabetically, i want to sort them by rank (which is just another key within that soldiers ...

Creating an URL without global variables

I have a code like this below, which gives me a $link that equals to: http://mydomain.com/image/photo.JPG if (!empty($_SESSION['item'][$i])) { $path = dirname(__FILE__).'/image/'.basename($_SESSION['item'][$i]); if (move_uploaded_file($_SESSION['item'][$i], $path)) global $url; if ( $url ) { $link = $ur...

PHP: How To Integrate HTML Purifier To Fileter User Submitted Data?

I have this script that collects data from users and I wanted to check their data for malicious code like XSS and SQL injections by using HTML Purifier http://htmlpurifier.org/ but how do I add it to my php form submission script? Here is my HTML purifier code require_once '../../htmlpurifier/library/HTMLPurifier.auto.php'; $config ...

Odd results using jQuery rating plugin

Hi, I use a for loop to generate my stars. I want them split into four so I use class="star {split:4}" I want 5 stars, so I need 20 loops (4splits * 5stars = 20). When it hits 17, it echo's checked="checked" However, in the browser, my script displays 30 stars with 25 and a quarter stars highlighted! Here's my line in PHP <inp...

Email pipe to php script working only sometimes

I have a php pipe script that receives an email, takes an attached *.csv from it and parses it. However, when the email is sent from where it is supposed to be coming from, it silently errors. But when I take that same email and resend it from my address it goes through just fine. is there any simple reason it could be doing this? ...

How to create a passsword protected pdf file

I'm using html2fpdf for creating PDF documents. Now once I have created that, I want to make sure that the PDF file is password protected. How can this be done in PHP? ...

Replacement relevance sorting for MySQL fulltext in InnoDB tables?

I am using MySQL InnoDB and want to do fulltext style searches on certain columns. What is the best way of sorting the results in order of relevance? I am trying to do something like: SELECT columns, (LENGTH(column_name) - LENGTH(REPLACE(column_name, '%searchterm%', ''))) AS score FROM table WHERE column_name LIKE '%searchterm%' ORD...

Replacing a specific bit of text in all php files on a server?

So I just got my sorry ass hacked, the hack put some obscure string in almost every one of the php files on my website. How can I remove every instance that line occurs? The code it added started with <?php so therefore I cannot simply replace it with blank, I need to delete it and move up the actual relevant code up one line as <?php c...

php xml SimpleXMLElement

<Placemark id="p1"></Placemark> <Placemark id="p2"></Placemark> <Placemark id="p3"></Placemark> <Placemark id="p4"></Placemark> hi,im using SimpleXMLElement in my php, my question is,how do i get placemark id 3? is that something like this ? $page = utf8_encode(file_get_contents($request_url)); $xml = new SimpleXMLElement($page); $xml...

Drupal: cache_menu refreshing after each node update

Hi, I have a problem with the cache_menu table, to which data are saved after each node update. With each addition of node, the question inserting data is increasing. At this time, has a length of 310k characters, and it needs about 410MB! Probably by a regular expression that processes it before executing (in db_query() function). Is it...

How should I pass the translated text to my object in my multilingual application?

Up until now, I have maintained a 'dictionary' table in my database, for example: +-----------+---------------------------------------+-----------------------------------------------+--------+ | phrase | en | fr | etc... | +-----------+---------------------...

PHP: Using browscap.ini on shared host. - ini_set() failing

I'm trying to use get_browser() , unfortunately my page is on a shared host, and I have no access to php.ini. I have downloaded the latest version of browscap.ini and placed in my document root. I have then added the following:- if (!ini_set('browscap', '/home/private stuff/browscap.ini')) { echo "Failed to set browscap"; } else...

Doctrine stupid or me stupid?

I want to use a single Doctrine install on our server and serve multiple websites. Naturally the models should be maintained in the websites' modelsfolder. I have everything up (and not running) like so: Doctrine @ /CustomFramework/Doctrine Websites @ /var/www/vhosts/custom1.com/ /var/www/vhosts/custom2.com/ Generating works fine...

How to work with file and streams in php

I have two class, one is Business Logic Class{BLO} and the other one is Data Access Class{DAO} and I have dependency in my BLO class to my Dao class. Basically am opening a csv file to write into it in my BLO class using inside its constructor as I am creating an object of BLO and passing in file from command prompt: Code: $this->fin...

Password Protect for fun

Hi there, I am working on a blog for my friend. I want to gift him the blog on his birthday. Just for some fun I want to restrict access to the blog. e.g. The website. www.myfriend.com opens with a splash screen. The screen has his picture and a question regarding him. these questions can be. If you know me.... What is my nickname...

Converting array to Drupal format

Hi all, This statement gives me the value I want in Drupal (namely the last user role): global $user; return (end($user->roles)); however I need to convert it to this format: return array( 0 => array('value' => value for value), // You'll usually want to stop here. Provide more values // if you want your 'default value' to be ...

Help with php code - need to add condition to make one link https

Hi, I have a wordpress blog and I need to make one of the pages secure. I have been told to make the link to that page point to https://claimpage.html as opposed to http://claimpage.html. The problem is I don't actually create the menu that links the user to the individual pages. This is done automatically by the code in the backgrou...

PHP & MySQL: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

I'm trying to Integrate HTML Purifier http://htmlpurifier.org/ to filter my user submitted data but I get the following error below. And I was wondering how can I fix this problem? I get the following error. on line 22: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given line 22 is. if (mysqli_num_rows($dbc) =...

Difference Running PHP From Eclipse And When Hosted

I am trying to use NuSoap in PHP 5.3. When I debug my script in Eclipse I get a lot of Deprecated warnings but the script still runs, however when I call the script thru Apache on my localhost the script terminates without any explanation. I'm not really a web-head yet, and being somewhat of a noob at this, I am at a loss as to why it ...