php

Accordions are nesting

I am building some accordions dynamically from some data that gets returned from the database, What should happen is that the user clicks on a link for the Blog, the blog accordion appears with header blog and click on that triggers the accordion affect. This bit works fine, the problem comes then the category blog has more than one of...

XDebug not working; extension_dir duplicated

I'm trying to get XDebug to work with PHP 5.2.11 installed with MacPorts on OSX Snow Leopard. I installed Pear with go-pear, then used PECL to install XDebug. I copied xdebug.so that it compiled to the extension_dir, /opt/local/lib/php/extensions/no-debug-non-zts-20060613/. I have an xdebug.ini file which (according to phpinfo) is loadin...

Create Array with specific key in PHP

Hello Everybody, seems like i'm blind at the moment. I want to build an empty array(). but instead of getting "0" as array-key i want to have a specific string as the key... Just to make it clear: $array = array(); gives me: [0] => array { } but i want it like that: ["string"] => array { } ...this really drives me crazy right n...

Efficient method to check object for null member variables?

I have a data processor class which can only perform its primary function once all its member variables have been assigned a value: class { public $firstName; public $lastName; public $ssn; public $accessKey; public function __construct($data = null) { if (is_array($data)) { // Assign the value o...

Character set in MySQL; Can't insert special characters, why?

I can't insert special characters. Whenever I try to, all characters BEFORE the special character gets inserted, but after the special character nothing is inserted into the field. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname,$conn); mysql_set_charset('utf-8', $conn); mys...

Mnemonic Password Generation Algorithm for QWERTY Keyboards

I've a "mnemonic" password generation function that goes something like this: function Mnemonic($mnemonic) { $result = null; $charset = array(str_split('aeiou', 1), str_split('bcdfghjklmnpqrstvwxyz', 1)); for ($i = 1; $i <= $mnemonic; $i++) { $result .= $charset[$i % 2][array_rand($charset[$i % 2])]; } ...

jQuery: remove class once element is clicked

Hello. I am stuck on a little jQuery problem. I have a collection of links (more than 50) generated from a php loop. When a user clicks on a link, the jQuery load event is called, and a php/mysql script (called page.php in the example below) is loaded into an empty div on the page. I would like the class (".classy") to removed from the ...

Parsing HTTP_RANGE header in PHP

Is there an existing way to parse the HTTP_RANGE header correctly in PHP? Thought I'd ask here before re-inventing the wheel. I am currently using preg_match('/bytes=(\d+)-(\d+)/', $_SERVER['HTTP_RANGE'], $matches); to parse the header but that does not cover all possible values of the header so I am wondering if there is a function ...

Is it possible to simulate closures in PHP 5.2.x not using globals?

Is it possible to simulate closures in PHP 5.2.x not using globals? I could think of a way that would pass the desired variables as extra parameters to the closure but that just doesn't feel like best practice. Any ideas? ...

I want to filter out the foregin links from my blog post, can some one help with me the regular expressions ?

I have blog data like: This is foreign <a href="xyz.com">link</a>, this is my site's <a href="mysite.com">link</a> and so on. What I want is to do is filter the links of foreign sites, i.e "<a href="xyz.com">link</a>". So that my final output is: This is foreign link, this is my site's <a href="mysite.com">link</a> and so on. I tri...

Another mysql JOIN question...

I have these tables: classified: classified_id (PK) price headline cat_id // THIS IS ANYTHING FROM 1 TO 30 DEPENDING ON CATEGORY. IT IS SO THAT I CAN LINK WHICH CATEGORY TO USE IN THE CATEGORY TABLE BELOW text etc... category: cat_id (PK) cat_name category_options: option_id (PK) cat_id (FK) // FOREIGN KEY FROM CATEGORY TABLE... optio...

How do I access the XML from a flickr.photos.search API call?

My client's system needs to access private photos from their Flickr account using the flickr.photos.search API call. I set it up and got the generated URL for that call. When I visit that URL in the browser, it outputs XML like it should. (API reference: http://www.flickr.com/services/api/flickr.photos.search.html) However, in PHP I wa...

Matching a user-inputted relative URL with preg_match

I have a project which requires using user input to include files into a PHP script. The user input could be any relative URL (EX:/folder1/folder2/file.jpg, /folder1/folder2/) Would the following be a fool-proof regexp to check if the input is sane: if(preg_match('/^(\/[-_a-zA-Z0-9]+)+\/?$/D', $_GET['loc'])) { //Location is good! }...

How to ping automatically to pingomatic in PHP ?

I want to ping automatically to pingomatic, when ever i update my blog, as it is done by the wordpress. Pingomatic uses the XMLRPC, but I don't know how it works. Can someone help me. ...

MySQL headache, should I or should I not?

I have a classifieds website. I am using SOLR for indexing and storing data. Then I also have a MySQL db with some more information about the classified which I dont store or index. Now, I have a pretty normalized db with 4 tables. Whenever ads are searched on the website, SOLR does the searching and returns an array of ID_numbers whic...

My MySQL query won't work

I have the following query which searched an episode guide database for user inputted data: $query = "SELECT * FROM epguide WHERE EpisodeTitle LIKE '%$trimmed%' OR Synopsis LIKE '%$trimmed%' OR Notes LIKE '%$trimmed%' ORDER BY o"; This works OK, but when I add 'Series = '...

What is the Best Workflow for Web Application?

I am about to begin a web application. Before I begin, I would like to get some advice as to what the best work flow/order is for creating a web application such as this. My project will consist of a server-side with PHP and MySQL. The client-side will be XHtml, CSS and jQuery. There will also be AJAX used. I'm sure that it can depend...

how to disable editing in a textbox and how to set default value of text box is eql to session variable

Hi Everyone I am editing a page and there i am asking again username and password for confirmation.. I want to pick username from session variable $_SESSION['employee']['password']=$row['Password']; and want that username displayed there(i am setting username box value=session username variable) but not for editing only password is a...

PHP: letting your own function work with a while loop

Hi i have this code $qVraagGroepenOp = "SELECT * FROM $tabele WHERE $where"; $rVraagGroepenOp = mysql_query ( $qVraagGroepenOp ); $aVraagGroepenOp = mysql_fetch_assoc ( $rVraagGroepenOp ) and i converted that to a fucntion vraagOp("testtable","testtable_ID = $id"); function vraagOp($table,$where) { $qVraagOp = "SELECT * FROM $ta...

PHP: Post data with Headers....not working.

Simple Script <?php $host = "mysite.com"; $path = "/test.php"; $data = "drivingMeCrazy"; $data = urlencode($data); header("POST $path HTTP/1.1\r\n" ); header("Host: $host\r\n" ); header("Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n" ); header("Content-length: " . strlen($data) . "\r\n" ); header("Connection: close...