php

Remove parent xml tag based on child value

For example, we have xml file with this format: <A> <B> <C></C> <D></D> <D></D> </B> </A> i need that: if all "D"-tags elements are empty, then we need to delete whole "A"-tag element and, of course, we need to do this with all "A"-tags in xml. ...

PHP - Use isset inside function not working..?

I have a PHP script that when loaded, check first if it was loaded via a POST, if not if GET['id'] is a number. Now I know I could do this like this: if(isset($_GET['id']) AND isNum($_GET['id'])) { ... } function isNum($data) { $data = sanitize($data); if ( ctype_digit($data) ) { return true; } else { ret...

Phing: Cutting out piece of code with Phing

I tried different phing filters regex aso. to cut out different pieces of code out of a build target. For that i use something like ##CUTSTART <?php // ...code to cut... ?> ##CUTEND This won't work because of no multiline support i guess: <filterchain> <replaceregexp> <regexp pattern="##CUTSTART(.*)##CUTEND" repla...

A couple problems re: CodeIgniter emailer

I have some problems with the email system for CodeIgniter: First, the emails I send out (registration, confirmations) are getting caught in standard spam filters in gmail and other mail clients. How do I get around this? How do companies like Facebook get their emails through consistently? Second, the mailer is working locally but o...

Caching generated images with PHP

I am trying to cache images which have been generated. You create a image by accessing the file by resize.php?width=x&height=y. If the image of that width and height does not exist I use imagemagick to create it. However if it does exist it is served to the visitor. The !file_exists($name) check works fine so processing is not done when...

My Twitter php script stopped working!

I'm using this PHP class for a Twitter script: twitter.slawcup.com/twitter.class.phps The script is: $t= new twitter(); $t->username='someuser'; $t->password='somepass'; $res = $t->update($tweet); if($res===false){ echo "ERROR<hr/>"; echo "<pre>"; print_r($t->responseInfo); echo "</pre>"; }else{ echo "SUCCESS<hr/>Status...

What characters are NOT escaped with a mysqli prepared statement?

Hey everyone, I'm trying to harden some of my PHP code and use mysqli prepared statements to better validate user input and prevent injection attacks. I switched away from mysqli_real_escape_string as it does not escape % and _. However, when I create my query as a mysqli prepared statement, the same flaw is still present. The query p...

What is the name of the standard error stream (Apache+php)

I want to put some text into the Apache error log (listens on the stderror error stream) from PHP using file_put_contents. I am missing the name of this stream, and whether I have to put :// or something similar before it. Thanks ...

A posterframe created with PHP won't work.

I am using PHP to create a poster frame for the Quicktime plugin, and all I am getting is Quicktime's broken plugin icon. I am positive that the URL is correct. (a copy-paste to the URL box works) The HTTP content-type header is equal to "image/jpeg". Does anyone have any ideas? ...

Jquery array submit

Hi, I have a page where there are 117 input fields. What i want is to submit them via Jquery ajax. What i am thinking is to make an array and send them by this way. I would like to ask how is it possible to take all inputs and then to put them in an array and then retrieve them from the php file (for example, should i do explode,or for e...

Arrange files by creation or modification with PHP

Is it possible to get the file names in a folder by the date of creation or modification? Thanks. ...

Is it best to make fewer calls to the database and output the results in an array?

I'm trying to create a more succinct way to make hundreds of db calls. Instead of writing the whole query out every time I wanted to output a single field, I tried to port the code into a class that did all the query work. This is the class I have so far: class Listing { /* Connect to the database */ private $mysql; function __constr...

How do i use a transparent image in a transparent image using GD?

I have tried every way I can find but the background is always black. Is there any way to keep the transparency of the first image when GD ises it in PHP? I'm using imagecopymerge to use the image. though i am not sure if this is the right way. imagecopymerge($dest, $char, 0, 0, 0, 0, 150, 300, 100); The image is like so: http://file...

Need advice to change my database design.

I need to change the way I am storing information in the DB. Because the query works slow with the old model I had developed. General problem is following. 1) I have list of courses, and each course has list of tags describing general content of the course. For instance, the course called "Database Management Systems" could have follow...

sql UPDATE, a calculation is used multiple times, can it just be calculated once?

Using: UPDATE `play` SET `counter1` = `counter1` + LEAST(`maxchange`, FLOOR(`x` / `y`) ), `counter2` = `counter2` - LEAST(`maxchange`, FLOOR(`x` / `y`) ), `x` = MOD(`x`, `y`) WHERE `x` > `y` AND `maxchange` > 0 As you can see, LEAST(maxchange, FLOOR(x / y) ) is used multiple times, but it should always have th...

Customizing setUp in PHPUnit

Hey all, I'm looking to run a bunch of tests with one object with different parameters in the setUp function. How do I do this? I tried using the @dataProvider, but that doesn't work with setUp I quickly found out.. Here's what I'd like to do (using @dataProvider): /* * @dataProvider provider */ function setUp($namespace, $args) { ...

Using PHP with the default Mac Apache + PHP installation

Hi, I'm starting to unravel the mysteries of PHP and I configured the pre-installed Snow Leopard PHP and activated the Apache server in the system preferences. So far so good: it works if you put a PHP file in your ~/Sites directory. Since I've my projects in a code/projects directory I created a symbolic link from the ~/Sites dir to t...

error in running recursion

if running function returns server misconfiguration error function build_path($cid) { $result = array(); $DB = new MySQLTable; $DB->TblName = 'shop_categories'; $where['cat_id']['='] = $DB->CleanQuest($cid); $res = $DB->Select('cat_id,cat_name,cat_parent', $where); if($res !== 'fal...

Unable to select dynamically generated form elements (ajax)

I have a main.php page the following code is hardcoded in main form <form action="test.php" method="POST"> the following is the code generated dynamically using AJAX <input type="checkbox" value="test" name="test[]"/> <input type="checkbox" value="test1" name="test[]"/> <input type="submit" value="go"> ideally speaking on clicki...

PHP RegEx - Get All Digits

I have this code: $string = "123456ABcd9999"; $answer = ereg("([0-9]*)", $string, $digits); echo $digits[0]; This outputs '123456'. I'd like it to output '1234569999' ie. all the digits. How can I achieve this. I've been trying lots of different regex things but can't figure it out. ...