php

Filter out categories in wordpress

Hey all, I was wondering how I can query posts that are not in a certain category. I tried query_posts('post_status=publish&post_type=post&category!=books&offset=5'); So I'm trying to get all published posts that are not in the category books, and then I have an offset of 5. Thanks, Matt Mueller ...

Writing a good Wordpress template

I was asked to write a custom template for a wordpress based site, and I'm noticing that themes are usually one big unreadable mess of PHP code mixed with HTML, with a terrible indenting on top of it -- even the default template follows this style. What I'm doing now is put all the PHP code first, then the markup with minimum PHP just f...

best practices in naming session variables

I was used to naming my session variables the "normal" way, kinda like when I want to keep track of user details, I name them: $_SESSION['username'] $_SESSION['email'] $_SESSION['id'] I am worried that they may be in conflict with other session data when I am browsing sites in the same browser, or will there not be any conflict at a...

Date difference in PHP?

I'm trying to compare two dates in PHP and figure out how many days apart the dates are. I am grabbing the first date from a MySQL database and the second date is the current date. The date in the MySQL database looks like this "2010-01-21 15:21:46" $date1 = date("Y-m-d", $product['hold_date']) $date2 = date("Y-m-d"); How can I compa...

Amazon SQS character encoding problem

Hi, I am trying to insert characters like ä, á, ó, í, â, etc in message body of Amazon SQS. But these characters get converted to some other characters in SQS (e.g. ä). Is there a way to solve this problem. Thanks ...

I think i have a vector image format, how do use it to draw an image in php?

I have found an image format that is being used by some applets. but i don't know what it is. I think it is some kind of vector graphics format that is used by the GD library. could someone help me decode it? I would like to use the raw data to produce a png, in php the data is being generated from squiggles drawn by the mouse. Is t...

How to crop image in Image_Canvas PHP PEAR package

I can't get it to work it just does nothing. I'm using Image_Canvas PEAR package on shared hosting it works but I can't crop image. My syntax is: $Canvas->setClipping(array('x0' => 10, 'y0' => 10, 'x1' => 200, 'y1' => 200)); Any ideas? ...

Problem wiht wrong file format (gif insted of jpg) when saving images from server - PHP

I am using this peace of PHP code to save and rename some images. foreach ($phones as &$value) { $link_img = $handle = @fopen($link_img, "r"); if ($handle) { while (!feof($handle)) { $buffer .= fgets($handle, 4096); } fclose($handle); $filename = "files/nokia_".$pho...

accepting user uploads best practices!

Hi, Im trying to add a multi page form, in php with zend framework, where users can list an item to my site. On the first page they enter details about the item(which is then stored in session), page two they can upload images, and then page three they can confirm the listing. If they confirm then the listing is added. What is the best...

How do I find out the index in a MySQL table

Hey guys, I'm programming in PHP5 & MySQL5 and I'd like to know how to figure out the index of an entry. To be clear, here's an example: I have 500 users in a table, I want to select the user johndoe and the index of that user, so if johndoe is the 100th user in my table, I want to be able to select the information for him in a similar w...

Using simplexml to get a node (and its children) by attribute

Using simplexml, is it possible to get the children of a node based on the parent's attributes. For example, I want to get a list of the variants in myItem1 (output would be small, large) Here is some psuedo code of what I'm after: foreach($xml->xpath('//family[@name="myItem1"]')->variants->children() as $child) { $child->getName()...

Sort through all attributes in XML tree with PHP XMLReader

I have some PHP code to turn an XML file into a CSV file. During testing, I am not creating a CSV file, just echoing the results in a CSV format. Whenever XMLReader reaches an empty element, it outputs all the attributes of the element. 1) Is there a way to output the attribute name with it's values i.e. (is there an $xml->AttributeNa...

multilevel menu with multilevel array

Dear all, just want to ask anyone here can solve this problem? I want to create a multilevel menu by generate with multilevel array. I just can't get perfect solution, it always got array_push error. My study the original idea come from http://www.weberdev.com/get_example-4830.html But still cannot match my need. This is My MySQL [...

Wordpress not using correct comments file?

Does anyone with experience using wordpress know why it would not use my comments.php file that is in a theme folder? ...

Eclipse PHP IDE - custom auto complete tags

New to Eclipse IDE and was wondering is there is a way of adding an auto complete/change so that if I type: mres it will translate it to mysql_real_escape_string() I know of the normal PHP code completion, but couldn't see anything about making custom shortcuts. Thanks, Niggles ...

Is it better to use look-behind or capture groups?

I'm not sure if one of these is 'better' then the other, and why it would be, but I've got an original string that looks like this: $string = '/random_length_user/file.php'; Now, there are two ways to match it, the first, using my new friend, the look-behind, and the 2nd, without: preg_match("%(?<=^/)([^/]*)%", $string, $capture); pr...

Connecting to MySQL via SSH with PHP

Is it possible to connect to a MySQL database, on remote server, via SSH using PHP that is installed on my local computer? I am a bit confused on this subject. My shared hosting provider suggests I use programs like MySQL Query Browser and Microsoft SQL Server Management Studio Express. I have done some research on SSH at php.net (as ...

Should you always end mysql queries with "or die?"

Example queries in some tutorials ALWAYS end with: or die(mysql_error()); I can see why you would would sometimes want to do this, but they even use this for queries that really shouldn't cause a problem. Is it a good practice to always use this, or are they just doing it to help you debug as you learn? ...

Is it possible to achieve paper-turn effect in HTML without using flash?

Hi, I'm aware of several flash-based commercial implementation like flashpageflip. But I'm wondering if it possible to achieve without using flash? Any help will be much appreciated. Thank you. Agung Indrawan. ...

CakePHP fills in the password field on create new user failure.

I'm getting funny behavior with CakePHP in my register new user form. It's a pretty basic username, email and password form. When the user types out and incomplete form it looks like this: http://imgur.com/fcpS5.png Of course creation of the new user fails because the password and email fields are empty. When the form errors are show...