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.
...
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...
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...
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...
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...
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...
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...
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
...
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?
...
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...
Is it possible to get the file names in a folder by the date of creation or modification?
Thanks.
...
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...
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...
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...
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...
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) {
...
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...
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...
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...
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.
...