php

Nusoap - fix empty xmlns attribute for the response

Hi, i have created a simple web service using Php Nusoap. its working correctly but the only thing missing is to add the default xmlns attribute to the response tag. Here is the copy of Response : <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOA...

How do you append for example ?lang=en_US to the url based on a cookie containing country code?

Hi. I have a code like this that extract the country code saved in the cookie. if (isset($_COOKIE['country'])) { $country = $_COOKIE['country']; $language = "eng"; if ($country == "NO"){ $language = "nor"; } ...

Telling the browser I'm done, but continue loading data

I have a php api that is being accessed via Flash. It grabs some content for flash and then does some book keeping. The problem is, the book keeping can take several seconds, and the php api can be accessed in the same manner anywhere from 10-500 times before the Flash App has loaded everything from it. Sense I'm using flash to access ...

print forums under common category

How would I do to print the forums under the common category? Like if I have 3 forums with the same cat_id I want to print them together under the category. You understand? Its hard to explain. Like this: Category 1 Forum 1 Forum 2 Category 2 Forum 45 Forum 74 Not Category 1 Forum 1 Category 1 Forum 2 CREATE TABLE `forums` ( `id` ...

reposition array elements based on a condition in php

So I have this array: $dates[0] = array('start'=>'2010-07-22', 'end'=>'2010-07-23'); $dates[1] = array('start'=>'2010-07-22', 'end'=>'0000-00-00'); $dates[2] = array('start'=>'2010-07-29', 'end'=>'0000-00-00'); $dates[3] = array('start'=>'2010-07-31', 'end'=>'2010-07-31'); $dates[4] = array('start'=>'2010-07-08', 'end'=>'2010-07-31'); $...

redirecting with if statment based on cookie using header('location:') gives weird error in firefox

Hi. I am trying to redirect my visitors to for example http://localhost/site/test.php?lang=en_USbased on the country code in the cookie like this: if (isset($_COOKIE['country'])) { $country = $_COOKIE['country']; header('Location: test.php?lang=en_US'); if ($country == "NO"){ header('Lo...

PHP & FPDF: Calculating justified text width

Hi guys, so I'm using FPDF in PHP to programmatically generate a PDF file from images and text (not HTML). One of the biggest issues I've been having is being able to wordwrap text around an image. My current algorithm looks like: Get text as an array of words Add words one at a time to a 'current line' variable, and call GetStringWid...

using regex to skip ahead all characters until a specific sequence of letters is found using negative lookahead

I'm alright with basic regular expressions, but I get a bit lost around pos/neg look aheads/behinds. I'm trying to pull the id # from this: [keyword stuff=otherstuff id=123 morestuff=stuff] There could be unlimited amounts of "stuff" before or after. I've been using The Regex Coach to help debug what I've tried, but I'm not moving for...

PHP code analayzer and other tools

I am new to PHP (worked around 7 years on ASP.NET) We are looking for some tools for PHP which we can use to make sure code quality is good. we are using Notepad++ as a IDE and SVN for code repository. ...

Mysterious empty database entry

In the comment leaving system on part of my website there is a weird blank entry that always remains above the latest real entry. I've looked in the database directly and there isn't a blank entry. Yet, on the top of all my comments, there is always an empty box that is formatted the same way as the rest of the comments. Where is this co...

why can not use property instead of __construct?

starting use oop why: class user { private $pdo; function __construct() { $this->pdo = singleton::get_instance()->PDO_connection(); } ... } this works fine. but this: class user { private $pdo = singleton::get_instance()->PDO_connection(); ... } this does not working. Error parse error, expecting...

regex match 0);

I have the following regular expression: SOMETHING(.*?),(1|0)\\); It needs to match SOMETHING then anything, then a comma, then 1 or 0 followed by ); but for some reason the last bracket isn't being matched, an example string: SOMETHINGdfsdfdsfd dsffdsdf dfsfds FEHEF777a ,0); the bold part is the ending. Am I escaping the ) wron...

Cakephp, dynamically write variables into css file upon load of view?

I'm working out a process to save actions that occur from jquery in my view in cakephp.. I figure an easy way to load the saved values, such as the width and height for a DIV, would be to have cakephp echo a variable as their width / height in the css file, much the same way it would do this in the view file.. I guess I'm not sure exactl...

Nusoap - fix empty xmlns attribute for the response

Hi, i have created a simple web service using Php Nusoap. its working correctly but the only thing missing is to add the default xmlns attribute to the response tag. Here is the copy of Response : <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns...

How to check if a string is in an array

I basically need a function to check whether a string's characters (each character) is in an array. My code isn't working so far, but here it is anyway :| $allowedChars = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","A","B","C","D","E","F","G","H","I","J","K","L","M",...

Recaptcha with magento

Hi all, I have installed recaptcha in my client's site which is not live yet But in development. The recaptcha was working fine till last week but when I'm checking it now it gives a "Input error: Invalid referer " instead of the recaptcha block. I am just wondering what might be the cause of this. Is it something to do with the public ...

what am i doing wrong?

This is really getting on my nerves, cant figure this one out I want it to look like this: http://i27.tinypic.com/f406tz.png But i cant get it to be like i want, it gets all f*ed up. It prints the rank on every row. If three players have same rank, i only wanna print the rank name for one. the rest replace with &nbsp; $old_rank = '';...

PHPunit - CLI PHP file includes/requires

For example if I have a php script called "RunAllTests.php" in '/var/www/tests/RunAllTests.php' and I execute phpunit within the that directory, the includes in "RunAllTests.php" are found. If I execute phpunit on that same file, from another directory, lets say '/var/www/', the included files in "RunAllTests.php" cannot be located. - "...

What is the best way to structure conditional logic?

It occurs to me that there are number of different ways to structure conditional logic. As far as I can see, as long as we set errors to end the script (or you can imagine the same examples but with a return in a function), then the following examples are equal: Example 1 if($condition1) { trigger_error("The script is now terminate...

Select from where field not equal to Mysql Php

Hi, I'm just wondering what kind of mysql command i could execute in php that would select all items from a certain table where columna is not equal to x and columnb is not equal to x so like select something from table where columna does not equal x and columnb does not equal x If anyone could help that would be great! Thanks ...