Re: [PHP] Regular Expression help need

2008-07-27 Thread James Dempster
On Fri, Jul 25, 2008 at 1:08 PM, Shelley [EMAIL PROTECTED] wrote:

 Hi Richard,

 Not exactly actually.

 What I mean is:
 Before: phi strongRichard/strong,  good morninglt;/p
 After:   phi strongRichard/stronggt;, amp; good morninglt;/p

 I hope it's clear now.

 On Fri, Jul 25, 2008 at 7:53 PM, Richard Heyes [EMAIL PROTECTED]
 wrote:

   How can I make a string with  (NOT amp;, gt;, lt; or quot;), , 
  xml
   compatible?
   What is the expression to use?
 
  Not entirely sure what you're after (try posting some before and after
  snippets), but by the sounds of it you don't need a regular expression
  - strtr() will work for you. Or str_replace().
 
  --
  Richard Heyes
  http://www.phpguru.org
 



 --
 Regards,
 Shelley



Is it possible for you to use a mixture of html_entity_decode, htmlentities
e.g.

?php
$content = html_entity_decode(',  good morninglt;');
echo 'phi strongRichard/strong'.htmlentities($content).'/p';

/James


Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread James Dempster
You might want to take a look at
http://php.net/manual/en/function.call-user-func-array.php



On Sat, Jul 12, 2008 at 4:57 PM, Luigi Perroti [EMAIL PROTECTED]
wrote:

 Hello, I'm trying to implement a few simple wrappers for some PHP
 functions.

 Here's an example of what I'm trying to do:

 function myWrapper() {
return defaultPhpFunction(func_get_args());
 }

 The example above is broken since I'm just passing an array to the original
 function.

 The only way to achieve the desired result that I've found is something
 like
 this:

 function myWrapper() {
$argsNumber = func_num_args();
if ($argsNumber == 1) {
return defaultPhpFunction(func_get_arg(0));
}
elseif ($argsNumber == 2) {
return defaultPhpFunction(func_get_arg(0), func_get_arg(1));
}
// ...
// ...
// ...
 }

 Since the above code is clumsy to say the least any advice would be
 welcome.
 Thanks for your time!



Re: [PHP] Passing arguments as they are received to another function

2008-07-12 Thread James Dempster
On the line where you have
self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
try this

call_user_func_array(array(self::$statement,'bindParam'),func_get_args());

see if that works...?


On Sat, Jul 12, 2008 at 5:36 PM, Luigi Perroti [EMAIL PROTECTED]
wrote:

 On Sat, Jul 12, 2008 at 6:00 PM, James Dempster wrote:

  You might want to take a look at
  http://php.net/manual/en/function.call-user-func-array.php



 Thank you very much for your suggestion.
 I've looked into it but I guess this doesn't work with what I'm trying to
 do, although what you suggested should indeed work perfectly with my
 previous example.
 Here's a snippet from the code that I'm having problems with:

 class MainDatabase {
private static $mainDatabase = NULL;
private static $statement = NULL;
//...
//...
//...
public static function prepare($query) {
self::$mainDatabase-beginTransaction();
self::$statement = self::$mainDatabase-prepare($query);
}
public static function bindParam() {


 self::$statement-call_user_func_array(array('PDOStatement','bindParam'),func_get_args());
// Results in:
// PHP Fatal error:  Call to undefined method
 PDOStatement::call_user_func_array() ...
// I've also tried with
 call_user_func_array('PDOStatement::fetchAll',func_get_args());
// but no luck, same error.
}
//...
//...
//...
 }

 I thought that a solution for the previous example would work in this
 scenario too, but I guess this isn't the case.
 Any further suggestions would be very welcome, thanks.



Re: [PHP] escape character in query string

2008-06-23 Thread James Dempster
for a space I belive a plus sign would work +
try the urlencode function it would make it much easier.

/James Dempster

On Mon, Jun 23, 2008 at 3:34 AM, joaquinbordado [EMAIL PROTECTED]
wrote:


 would someone happen to know the escape character for query string?

 here is my querysting my.php?message=Hello%PHP%0AHow%was%your%day?


 the output should be

 Hello PHP
  How was your day?

 --
 View this message in context:
 http://www.nabble.com/escape-character-in-query-string-tp18061596p18061596.html
 Sent from the PHP - General mailing list archive at Nabble.com.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] climb up the path

2008-06-18 Thread James Dempster
Personally I use.

?php require_once(dirname(dirname(__FILE__)).'/config.php');

I think it's what most people do.

/James Dempster

On Wed, Jun 18, 2008 at 1:31 PM, Iv Ray [EMAIL PROTECTED] wrote:

 hi all,

 i need a way to get the path to the parent folder of the folder i am in.
 one dirty way i found is this -

 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR .
 ..  . DIRECTORY_SEPARATOR .
 config.php);

 i can also explode() and reassemble all folders except the last, but this
 looks also dirty...

 is there a direct way?

 iv

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Avoid object twice

2008-06-03 Thread James Dempster
I don't see how it's possible for you to get Hello after Good, when the
file that cause's Hello is required to do Good

/James

On Mon, Jun 2, 2008 at 2:00 PM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 Please take a look at code.

 a.php

 $obj=new my(Hello);
 $obj-buff();


 Class my{

 private $word;
 function __construct($getword){
   $this-word=$getword;
 }
 public function buff(){
 echo $this-word.br /;
 }
 --


 -b.php---

 function __autoload($class_name) {
include_once $class_name . '.php';
 }


 $objref=new my(Good);
 $objref-buff();
 



 I get an Echo;

 Good
 Hello
 Hello

 I do not need to get Hello twice.

 When I b.php , $obj=new my(Hello) is loaded.


 Do you have any adia to avoid load $obj in a.php twice?

 Regards,
 Yui

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Avoid object twice

2008-06-03 Thread James Dempster
I suggest you don't put code other than class structures in class files.
Also don't execute My.php just execute b.php which though __autoload
includes My.php.

-b.php
?php
function __autoload($class_name) {
  include_once $class_name . '.php';
}

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
}


/James Dempster

On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 HI!

 I had mistake in code in php.

 When I excute My.php, it say Hello
 When I excute b.php, it say
 Hello
 Good

 I would like to execute b.php and show
 only Good

 If you know it ,please teach me!

 Here is code below;

 -b.php
 ?php
 function __autoload($class_name) {
   include_once $class_name . '.php';
 }


 $objref=new My(Good);
 $objref-buff();
 ?
 ---

 --My.php--
 ?php
 $obj=new My(Hello);
 $obj-buff();


 Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
 }
 ?
 --
 Regards,
 Yui


 2008/6/3 James Dempster [EMAIL PROTECTED]:
  I don't see how it's possible for you to get Hello after Good, when
 the
  file that cause's Hello is required to do Good
 
  /James
 
  On Mon, Jun 2, 2008 at 2:00 PM, Yui Hiroaki [EMAIL PROTECTED]
 wrote:
 
  Please take a look at code.
 
  a.php
 
  $obj=new my(Hello);
  $obj-buff();
 
 
  Class my{
 
  private $word;
  function __construct($getword){
$this-word=$getword;
  }
  public function buff(){
  echo $this-word.br /;
  }
  --
 
 
  -b.php---
 
  function __autoload($class_name) {
 include_once $class_name . '.php';
  }
 
 
  $objref=new my(Good);
  $objref-buff();
  
 
 
 
  I get an Echo;
 
  Good
  Hello
  Hello
 
  I do not need to get Hello twice.
 
  When I b.php , $obj=new my(Hello) is loaded.
 
 
  Do you have any adia to avoid load $obj in a.php twice?
 
  Regards,
  Yui
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 



Re: [PHP] Storing £ (pound sterling) sign and displaying in HTML email

2008-06-02 Thread James Dempster
This is most likely a character encoding issue. Check that the html encoding
is set to the same type as what your storing it as in mysql.

/James

On Mon, Jun 2, 2008 at 10:26 PM, Graham Cossey [EMAIL PROTECTED]
wrote:

 Could someone please point me in the right direction here please?

 I have a form textarea field (submitted using POST) that accepts free
 text that will include the likes of '£' (pound sterling symbol) that
 is written to a MySql database and later retrieved to output into an
 HTML email.

 I have been experimenting with htmlentities, htmlspecialchars and
 addslashes but still have the problem whereby I get ACirc;
 preceeding the pound;

 Could someone kindly suggest what I'm doing wrong and what function(s)
 I should be looking into?

 Thanks

 --
 Graham

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Good HTML parser needed

2008-05-14 Thread James Dempster

 Purifier will not only remove all malicious code (better known as XSS)
 with a thoroughly audited, secure yet permissive whitelist, it will also
 make sure your documents are *standards compliant.*


Set it up how you want it.
--
/James

On Wed, May 14, 2008 at 4:38 PM, Robert Cummings [EMAIL PROTECTED]
wrote:


 On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote:
  On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED]
 wrote:
   http://htmlpurifier.org/
  
--
/James
  
 
  This is the only real solution.

 That depends... if I'm the webmaster and I want to input arbitrary HTML,
 then htmlpurifier is unnecessary.

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP




Re: [PHP] Good HTML parser needed

2008-05-13 Thread James Dempster
http://htmlpurifier.org/

--
/James

On Tue, May 13, 2008 at 4:34 AM, Shelley [EMAIL PROTECTED] wrote:

 Hi all,

 The fact is that I have a site that allow users to post hypertext
 articles.
 However, I saw that sometimes, because of their careless input,
 the articles is not rendered correctly.

 I want to know whether there are some good HTML parsers written in PHP.

 That is,
 the parser checks whether html tags like table, tr, td, div, dt, dl, dd,
 script, ul,
 li, span, h1, h2, etc. are nested correctly. If any tags not matched, just
 remove them.

 Any suggection is greatly appreciated.

 --
 Regards,
 Shelley



Re: [PHP] Replacing accented characters by non-accented characters

2008-05-12 Thread James Dempster
maybe try iconv (http://uk.php.net/manual/en/function.iconv.php)
e.g.

echo iconv('ISO-8859-1', 'UTF-8//TRANSLIT', 'français');

--
/James

On Mon, May 12, 2008 at 4:09 PM, Yannick Warnier [EMAIL PROTECTED]
wrote:

 Hello,

 I've been trying to find something nice to transform an accentuated
 string into a non-accentuated string. Obviously, I'm mostly playing
 inside the European languages, but any method that could transform
 arabic or asian characters to plain non-accentuated characters would be
 perfect.

 I have found a number of solutions, ranging from str_replace() for every
 known accentuated character to strtr() to a preg_replace() of a
 conversion of the string to html characters then removing the  and
 the alteration string (acute, grave, circ, ...).

 I must say the last one seems to work better because it's less affected
 by charset changes, but it still seems awfully slow to me and I would
 like to know if there is any function that exists that could do that for
 me?

 Yannick


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Replacing accented characters by non-accented characters

2008-05-12 Thread James Dempster
oops wrong way round
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT', 'français');

On Mon, May 12, 2008 at 4:27 PM, James Dempster [EMAIL PROTECTED] wrote:

 maybe try iconv (http://uk.php.net/manual/en/function.iconv.php)
 e.g.

 echo iconv('ISO-8859-1', 'UTF-8//TRANSLIT', 'français');

 --
 /James


 On Mon, May 12, 2008 at 4:09 PM, Yannick Warnier [EMAIL PROTECTED]
 wrote:

  Hello,
 
  I've been trying to find something nice to transform an accentuated
  string into a non-accentuated string. Obviously, I'm mostly playing
  inside the European languages, but any method that could transform
  arabic or asian characters to plain non-accentuated characters would be
  perfect.
 
  I have found a number of solutions, ranging from str_replace() for every
  known accentuated character to strtr() to a preg_replace() of a
  conversion of the string to html characters then removing the  and
  the alteration string (acute, grave, circ, ...).
 
  I must say the last one seems to work better because it's less affected
  by charset changes, but it still seems awfully slow to me and I would
  like to know if there is any function that exists that could do that for
  me?
 
  Yannick
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 



Re: [PHP] Get array as string --Help

2008-05-09 Thread James Dempster
serialize

--
/James

On Fri, May 9, 2008 at 10:40 AM, Shelley [EMAIL PROTECTED] wrote:

 Hi all,

 If I have an array like this:
 $arr = array (
'c' = 'd',
'e' = 'f');

 How can I convert this array into a string? I want to write an array into a
 file.

 Thanks in advance.

 --
 Regards,
 Shelley



Re: [PHP] Re: Question regarding fopen

2008-05-01 Thread James Dempster
?php

$foldersystem = getcwd().'/test1';
$id = '54961';
$imgstr = 'tdtdtdtd'; //uniqid();
$i = 2;

$imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg';
echo $imagenamesmall; // For debugging purposses -- returns exactly what I
want.

//attempt to create folder
mkdir($foldersystem);
chmod($foldersystem, 0777);

//save picture
if(!($handle = fopen($imagenamesmall, 'w'))){
   echo Cannot open file (31);
   exit;
}

This code works for me. How about you ?

--
/James

On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote:

 Does anyone have an idea? Is this a bug in PHP? Because when I add or
 remove one static letter in the filename, it does work. And if I don't
 the file is created, but the $imgstr (random 8 characters) is replaced
 by a totally different value (also random 8 characters).. I have no
 idea where this new value comes from.

 regards,
 Joep

 2008/4/29 Joep Roebroek [EMAIL PROTECTED]:
  Hi, I'm having a strange problem with fopen
 
   For clearence, here is the phpinfo page:
   http://www.grondengoed.nl/phpinfo.php
 
   I will shortly explain the problem I'm having:
  $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' .
   $i . '.jpg';
  echo $imagenamesmall; // For debugging purposses -- returns
   exactly what I want.
 
  //attempt to create folder
  @mkdir($foldersystem);
  @chmod($foldersystem, 0777);
 
 
  //save picture
  if(!($handle = fopen($imagenamesmall, 'w'))){
  echo Cannot open file (31);
  exit;
  }
 
 //$imagesmall, contains the image resource
 
  if(fwrite($handle, $imagesmall) === FALSE) {
  echo Cannot write to file (32);
  exit;
  }
 
  fclose($handle);
 
   Erverything works perfectly fine.But one thing, it doesn't give the
   file the name that it should get. A name for instance has to be:
   54961tdtdtdtd-s0.jpg
   The number is the id of the database row, the 8 characters are random.
   -s stands for small and 0 is the picture index.
   When I echo the value, I get what I want. But when I save it, the
   random 8 character string had become a totally different 8 character
   string :S.
 
   I have googled and checked things over and over again, cost me hours
   and I still haven't found the reason. What is noticeable is that when
   I leave one character away from the name, the value IS what it schould
   be:S.
 
   I really hope you can help me, if you need further info yust ask.
 
   Thanks in advance.
 
   regards,
 
   Joep Roebroek
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Question regarding fopen

2008-05-01 Thread James Dempster
Do you have a piece of example code that will reproduce the problem?

--
/James

On Thu, May 1, 2008 at 12:26 PM, Joep Roebroek [EMAIL PROTECTED] wrote:

 Strangely enough.. It does.. But I have also tried adding a letter
 (which gives me the good result) and then renaming it... But then the
 value is wrong again :S

 I've never had a problem like this.. Very strange..

 2008/5/1 James Dempster [EMAIL PROTECTED]:
  ?php
 
  $foldersystem = getcwd().'/test1';
   $id = '54961';
  $imgstr = 'tdtdtdtd'; //uniqid();
   $i = 2;
 
 
  $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i .
 '.jpg';
   echo $imagenamesmall; // For debugging purposses -- returns exactly
 what I
  want.
 
   //attempt to create folder
  mkdir($foldersystem);
   chmod($foldersystem, 0777);
 
  //save picture
   if(!($handle = fopen($imagenamesmall, 'w'))){
 echo Cannot open file (31);
  exit;
  }
 
   This code works for me. How about you ?
 
  --
   /James
 
 
 
  On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED]
 wrote:
  
  
  
   Does anyone have an idea? Is this a bug in PHP? Because when I add or
   remove one static letter in the filename, it does work. And if I don't
   the file is created, but the $imgstr (random 8 characters) is replaced
   by a totally different value (also random 8 characters).. I have no
   idea where this new value comes from.
  
   regards,
   Joep
  
   2008/4/29 Joep Roebroek [EMAIL PROTECTED]:
  
  
  
  
  
  
Hi, I'm having a strange problem with fopen
   
 For clearence, here is the phpinfo page:
 http://www.grondengoed.nl/phpinfo.php
   
 I will shortly explain the problem I'm having:
$imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s'
 .
 $i . '.jpg';
echo $imagenamesmall; // For debugging purposses -- returns
 exactly what I want.
   
//attempt to create folder
@mkdir($foldersystem);
@chmod($foldersystem, 0777);
   
   
//save picture
if(!($handle = fopen($imagenamesmall, 'w'))){
echo Cannot open file (31);
exit;
}
   
   //$imagesmall, contains the image resource
   
if(fwrite($handle, $imagesmall) === FALSE) {
echo Cannot write to file (32);
exit;
}
   
fclose($handle);
   
 Erverything works perfectly fine.But one thing, it doesn't give the
 file the name that it should get. A name for instance has to be:
 54961tdtdtdtd-s0.jpg
 The number is the id of the database row, the 8 characters are
 random.
 -s stands for small and 0 is the picture index.
 When I echo the value, I get what I want. But when I save it, the
 random 8 character string had become a totally different 8
 character
 string :S.
   
 I have googled and checked things over and over again, cost me
 hours
 and I still haven't found the reason. What is noticeable is that
 when
 I leave one character away from the name, the value IS what it
 schould
 be:S.
   
 I really hope you can help me, if you need further info yust ask.
   
 Thanks in advance.
   
 regards,
   
 Joep Roebroek
   
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 



Re: [PHP] Help with preg_match_all regex for alt tags

2008-04-29 Thread James Dempster
try preg_match_all('/img[^]*alt=([^]*)/i', $subject, $result);

--
/James

On Tue, Apr 29, 2008 at 8:18 PM, Joe Harman [EMAIL PROTECTED] wrote:

 Hey y'all ... i am having alittle trouble with this regex for finding
 ALT tags for images...


 Here is my statement

 
 preg_match_all('alt[^]*?.*?[^]'si, $output, $alt_tags);

 Evaluating

 
 [other html code]... img src=images/race-parts_wheels-tires.jpg
 vspace=2 border=0 alt=Wheel  Tire Acc / ...[other html code]

 I am currently getting

 
 alt=Wheel  Tire Acc /

 I want this result

 
 alt=Shopping Cart


 Thanks for your help
 --
 Joe Harman

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP debugger

2008-04-28 Thread James Dempster
I'd suggest Xdebug http://xdebug.org/

--
/James

On Mon, Apr 28, 2008 at 12:00 PM, J. Manuel Velasco - UBILIBET 
[EMAIL PROTECTED] wrote:

  Hello,

 Anybody knows a good debugger for PHP and basic usage?

 I've found: http://dd.cron.ru/dbg/, what do you think about it ?

 Thanks.
 --



Re: [PHP] Big companies that use PHP?

2008-04-24 Thread James Dempster
there is the php easter
eggshttp://shiflett.org/blog/2006/feb/php-easter-eggswhich show that
it's php. but most large companies turn that off.

 expose_php = 'off'


--
/James

On Thu, Apr 24, 2008 at 8:54 AM, Tom Chubb [EMAIL PROTECTED] wrote:

 On 23/04/2008, Thiago Pojda [EMAIL PROTECTED] wrote:
  Hey guys,
 
 
 
  I've been asked this common question: What big companies use PHP in big
  apps?
 
 
 
  I don't know where to find this kind of stuff and, well. here I am :)
 
 
 
 
 
  Do any of you know?
 
 
 
  And what % of the web market share does PHP take?
 
 
 
 
 
  Thanks,
 
  Thiago Pojda
 
 

 Wasn't there something you could append to any file in the URL that
 would show if it had been parsed using PHP?

 --
 Tom Chubb
 [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] need pop-up in progress alert

2008-04-18 Thread James Dempster
As a suggestion you could store a progress of the function in the session
and make regular calls via ajax back to the server for the progress.

--
/James

On Fri, Apr 18, 2008 at 3:42 PM, Steve Holmes [EMAIL PROTECTED] wrote:

 Greetings, I'm relatively new to PHP and I've been lurking for a while on
 the list, but now I need a pointer or two.
 I have an application which has one function that does a lengthy process
 (installing a piece of software) and I don't want the user to panic
 thinking
 nothing is going on. So I want to put up a 'working' box or a progress
 bar.
 I have no idea how to do that. I haven't dipped my toes into pear yet. I
 don't even know how to install or use a pear module. If there is something
 available that doesn't require pear knowledge so much the better, I guess,
 but if this is the straw that gets me into pear, so be it.
 So if someone could point me in the right direction I'd really appreciate
 it.

 Thanks,
 Steve Holmes
 Purdue University