php

Wordpress recursion through comments

Hi, I have edited my theme in Wordpress to show the 20 most recent comments to each post on the post list. Works fine and all. However I have nested comments enabled on my WP and would like to show nesting within the 20 recent comments. That is being if a comment is a reply to another comment which is in the recent 20 comments then nes...

MySQL Query with PHP function compare?

Hello, What I want to do is while executing MySQL query, passing column data into a PHP function and comparing the result with WHERE clause... Something like that, I have the slug() function which I wrote in PHP and my query will be something like; SELECT * FROM articles WHERE slug(author) = "james-taylor"; So the query will select ...

What is the best way to clean public input?

So I have a form that accepts some input from a user that may at a later time be represented on the page. The way I'm thinking of doing this from a security point of view is to take the input, apply the mysql_real_escape_string() function to all input, then insert using a prepared statement. When retrieving the data, I'll do a htmlspec...

How to tell which PHP file was used to "include" another?

In PHP when using the include function is the a way to tell from the inserted file which file inserted you? For example, I use the following line often through my code: include 'header.php'; Is there a way to tell from inside header.php what PHP file inserted you? ...

Checking a URL is valid (from php soap client)

Hi there I am writing a web app which will allow the user to specify a URL for a SoapClient. I wanted to validate that php can connect to the client when the user submits a form. I thouhgt I could do this via try catch or set_error_handler (or some combination of the two). However it looks like this is not possible for fatal errors. Is ...

Checking internet connection with command-line PHP on linux

I'm using command-line PHP on linux to open bluetooth dialup connection, and I need a quick'n'dirty way to check if internet connection is active. Well, doesn't have to be dirty, but quick is appreciated. :) Using exec to run external commands is not a problem. I'm thinking of pinging some stable server (e.g. google), but I'm wondering ...

Fastest way to load/include PHP template?

I have a function that loops through different types of listings pulled from MySQL and displays them as a Facebook-esque "feed". Each type of listing has a different appearance, and therefore requires a different template. Here is the below function example might be called 100 times (if there are 100 listings): function display_listing...

Whats the most efficient way to do updates with Zend_Db and MySQL.

I have a method which loops over an array of objects and commits an update statement per object (a total of 15 objects with 5 fields each). This may have to be performed hundreds or even thousands of times a second, depending on the level of traffic we get. What is the best way (aside from hardware considerations) to ease the load this ...

built in Soap extension php5 passing in params as associative array

I have this xml I'm wanting to pass to this web service function <UserName>myuser</UserName> <Password>password</Password> <User> <AddCoverCode /> <title>sdadasdsa</title> </User> </CreateNewUser>','',array(),'document', 'literal'); I'm using the soap extension buit in php5. Is this what I'm supposed to be passing in the so...

Compressing with Java Decompressing with PHP

I have a situation where a servlet is providing compressed data to a PHP script. I compress the data on the Java side no problem, but PHP seems unable to decompress. Here is the relevent code snippets Java Side: OutputStream o=response.getOutputStream(); GZIPOutputStream gz=new GZIPOutputStream(o); gz.write(GridCoder.encode(rs,id...

Approve submitted data

I notices more spam in my submitted data. How can I make a moderate stAge? For ex, user submits dAta to be entered mysql then I can approve before it is enetered into db where it would be automatically published. 9/11/2009: So I will test the Y/N method and then get back to u guys but I suspct I will have a problem with moderating (te...

Debugging php on ubuntu 9.04?

Is there any IDE (linux based) for PHP that can be used to debug? Or any one can help me to configure debug properties/settings of eclipse? Now i am using ubuntu 9.04. i have tried to debug but havn't tried to configure, because i don't know how to configure it. can you tell me the exact way? please help me. ...

Determining elapsed time

I have two times in PHP and I would like to determine the elapsed hours and minutes. For instance: 8:30 to 10:00 would be 1:30 ...

jquery functions not working properly after .html reload

I have a page with a list of items initially loaded from a include_once('show_calendarV2.php'); line. Next to each item is a delete icon that triggers the following jquery to delete the item from the db and then update the page. $('.delete_schedule_item').click( function() { var id = $(this).next('input[type=hidden]').attr('value'...

sum in query / subquery

Table has the following info: date |vendor|sales|percent| -------------------------- 2009-03-03| 10 |13.50| 1.30 | 2009-03-10| 10 |42.50| 4.25 | 2009-03-03| 21 |23.50| 2.30 | 2009-03-10| 21 |32.50| 3.25 | 2009-03-03| 18 |53.50| 5.30 | 2009-03-10| 18 |44.50| 4.45 | I want it to sort into separate tables depending on d...

Where does this session come from?

I have a header.html which start with session_start();. Then the following code, $_SESSION['cart'][$sw_id] is not set, but suddenly came out. Q1. Can you start session in this way? Q2. How come you can increment quantity of purchase with $_SESSION['cart'][$sw_id]++? It seems to me incrementing id number. <?php # Script 5.7 - cart.php ...

Optimum filesystem structure for scripting language MVC applications

When I speak of scripting languages I am speaking of languages like Python, Perl, and (in my case) PHP. After using CodeIgniter, Zend, and lots of other fun MVC systems it seems clear that one thing one one seems to agree on is the folder structure (alongWithOTher things_like_that). This is really causing a problem for me because I can't...

PHP syntax errors

My ISPs PHP server is now returning 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. On what I thought was valid php, i.e. if ( $_REQUEST[ 'some_data' ] == null ) { echo "<p>No data</p>"; } else { echo "<p>Some data</p>"; } I have tried turning on error reporting ...

A recursive remove directory function for PHP?

I am using PHP to move the contents of a images subfolder GalleryName/images/ into another folder. After the move, I need to delete the GalleryName directory and everything else inside it. I know that rmdir() won't work unless the directory is empty. I've spent a while trying to build a recursive function to scandir() starting fr...

jQuery update a Div with a PHP script

I have absolutely no idea how to do this, so I'm just gonna go ahead and ask. What I want to do is update the contents of a div with a PHP script I have in an external file, called send.php. So I have a div like this: <div class="classname"> </div> And I want to post data to this send.php file, and then update that div with whatev...