Re: [PHP] Converting a Unicode code to related charachter

2011-12-19 Thread Ali Asghar Toraby Parizy
Thanks for your reply. But the function that I've written, converts a code
to a character. for example if input is u0631 the output will be: ARABIC
LETTER REH ر
But I think that use of this json_decode() is a little nonsense! I didn't
find a straightforward function to do this ,though I've searched a lot.

On Mon, Dec 19, 2011 at 11:51 AM, Francisco M. Marzoa Alonso 
franci...@marzoa.com wrote:

 Hello,

 Can you please provide an example of real input and the output expected?

 I'm not sure about what you want to do. Anyway, for converting utf-8
 characters into plain ASCII equivalents chars, you can use iconv
 translit feature like:

 $rtn = iconv ('UTF-8', 'ASCII//TRANSLIT', $string);

 You may need to set locale before using setlocale. For Spanish strings I
 use this code:

 setlocale (LC_ALL, 'es_ES.UTF-8');
 $rtn = iconv ('UTF-8', 'ASCII//TRANSLIT', $string);

 If I use for example this as $string:

 'ביםףתס'

 I will get this as $rtn at return:

 'aeioun'

 Regards,





 On 18/12/11 10:33, Ali Asghar Toraby Parizy wrote:
  Hi.
  As I was writing a php code last week, I struggled with a function that
 was
  supposed to convert Unicode code to a character. At last I wrote this
  function:
 
  function unicodeToChr($param) {
 
  $a =json_decode('{t:'.$param.'}');
 
  return $a-t;
  }
 
 
  In this function the $param should be something like '\u0627'. I want to
  know if it's acceptable to use this function? Does exist any better
  solution to do that?
  Thanks.
 




[PHP] number_format

2011-12-19 Thread Floyd Resler
In the previous version of PHP we were using, I could pass a string to 
number_format and it would just change it to a 0 without complaint.  With 5.3.6 
I get an expects double error.  I don't suppose there's a way to make it work 
like it used to???  I'm dealing with really old code that wasn't very well 
structured.

Thanks!
Floyd


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



Re: [PHP] number_format

2011-12-19 Thread Bastien Koert
On Mon, Dec 19, 2011 at 9:19 AM, Floyd Resler fres...@adex-intl.com wrote:
 In the previous version of PHP we were using, I could pass a string to 
 number_format and it would just change it to a 0 without complaint.  With 
 5.3.6 I get an expects double error.  I don't suppose there's a way to make 
 it work like it used to???  I'm dealing with really old code that wasn't very 
 well structured.

 Thanks!
 Floyd


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



Could you check it before formatting? Or if the data is coming from
the db, force it to 0 if null?

$var = (is_double($number_var)) ? $number_var : 0;



-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] number_format

2011-12-19 Thread Ken Robinson

Quoting Floyd Resler fres...@adex-intl.com:

In the previous version of PHP we were using, I could pass a string  
to number_format and it would just change it to a 0 without  
complaint.  With 5.3.6 I get an expects double error.  I don't  
suppose there's a way to make it work like it used to???  I'm  
dealing with really old code that wasn't very well structured.


The way I would get around this would be to create a function like this:

function my_number_format($number, $decimals = 0, $dec_point = '.',  
$thousands_sep = ',') {

   $number += 0;  //convert value to a number.
   return number_format($number, $decimals, $dec_point, $thousands_sep);
}

The just do a global replace of number_format with my_number_format.

That should work, although I haven't tested it...

Ken


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



Re: [PHP] number_format

2011-12-19 Thread Robert Cummings

On 11-12-19 11:08 AM, Bastien Koert wrote:

On Mon, Dec 19, 2011 at 9:19 AM, Floyd Reslerfres...@adex-intl.com  wrote:

In the previous version of PHP we were using, I could pass a string to number_format and 
it would just change it to a 0 without complaint.  With 5.3.6 I get an expects 
double error.  I don't suppose there's a way to make it work like it used to???  
I'm dealing with really old code that wasn't very well structured.

Thanks!
Floyd


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




Could you check it before formatting? Or if the data is coming from
the db, force it to 0 if null?

$var = (is_double($number_var)) ? $number_var : 0;


Or possibly:

?php

number_format( (float)$your_input, 2 );

?

Cheers,
Rob.







--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] number_format

2011-12-19 Thread Floyd Resler

On Dec 19, 2011, at 11:38 AM, Robert Cummings wrote:

 On 11-12-19 11:08 AM, Bastien Koert wrote:
 On Mon, Dec 19, 2011 at 9:19 AM, Floyd Reslerfres...@adex-intl.com  wrote:
 In the previous version of PHP we were using, I could pass a string to 
 number_format and it would just change it to a 0 without complaint.  With 
 5.3.6 I get an expects double error.  I don't suppose there's a way to 
 make it work like it used to???  I'm dealing with really old code that 
 wasn't very well structured.
 
 Thanks!
 Floyd
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Could you check it before formatting? Or if the data is coming from
 the db, force it to 0 if null?
 
 $var = (is_double($number_var)) ? $number_var : 0;
 
 Or possibly:
 
 ?php
 
 number_format( (float)$your_input, 2 );
 
 ?
 
 Cheers,
 Rob.
 

That worked beautifully!

Thanks!
Floyd




Re: [PHP] Working on a Subsummary Report

2011-12-19 Thread Jim Lucas
On 12/17/2011 4:21 PM, DealTek wrote:
 
 On Dec 16, 2011, at 12:56 PM, Jim Lucas wrote:


 1) What does your db schema look like?
 2) What SQL do you currently use?
 3) What criteria do you want to use to sort the data?
 4) Will the output be plaintext, html, etc?
 5) Is this going to be used to import into another app, or display  
 printing?

 
 Hi Jim - sorry I didn't see this earlier...
 
 
 1 - schema - think of a basic 2 table system  parent table and line items 
 table... - but really all the important fields are in the child line items...
 2 - mysql 5.xx
 3 - sort 1st by date (all records happen 1st of every month) then product 
 (only 2 products needed for this)
 4 - html for now
 5 - for now just display and printing like:
 
 
 JAN 2011
 --- PRODUCT 1
 
 data row 1
 data row 2
 
 --- PRODUCT 2
 
 data row 3
 data row 4
 
 like that...
 
 
 - thanks for checking this out
 
 
 
 
 --
 Thanks,
 Dave - DealTek
 deal...@gmail.com
 [db-11]

Well, by the sounds of it, you are using a join to combine the two tables into
one result set and you have doubling up on the parent information.

I would do it like this.

$SQL = 'SELECT p_id, month_name, prod_id, l_id, descr';

$results = query($SQL);

while ( $r = fetch_assoc($results) ) {
  $data[$r['p_id']]['descr'] = $r['month_name'];
  $data[$r['p_id']]['x'][$r['prod_id']]['descr'] = $r['descr'];
  $data[$r['p_id']]['x'][$r['prod_id']]['x'][$r['l_id']] = $r;
}

print_r($data);

Now, use instead of looping through the result set multiple times, us the
$dataSet array to loop through it once.

foreach ( $data AS $months ) {
  echo {$months['month']}\n;
  foreach ( $months['x'] AS $prod_id = $products ) {
echo --- {$products['descr']} #{$prod_id}\n\n;
foreach ( $products['x'] AS $product ) {
  echo str_pad($product['l_id'], 16, ' ', STR_PAD_LEFT), '  ',
   str_pad($product['descr'], 32, ' ', STR_PAD_RIGHT), PHP_EOL;
}
echo PHP_EOL;
  }
  echo PHP_EOL;
}

YMMV - This is completely untested,  It should give you an idea about how to
prepare/store the data and then display it.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



[PHP] PHP page source charset

2011-12-19 Thread Rick Dwyer

Hello all.

When I set my page charset from iso-8859-1 to utf-8, when I run it  
through the W3C validator, the validator returns an error that it  
can't validate the page because of an illegal character not covered by  
UTF-8.



Sorry, I am unable to validate this document because on line 199 it  
contained one or more bytes that I cannot interpret as utf-8(in other  
words, the bytes found are not valid values in the specified Character  
Encoding). Please check both the content of the file and the character  
encoding indication.

The error was: utf8 \x99 does not map to Unicode

Line 199 is a line with my open PHP declaration:
?php

Not sure why W3C is having a hard time with this.  Any ideas?

 --Rick


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



[PHP] questions about fastcgi

2011-12-19 Thread Rui Hu
hi,

I encountered a problem while configured virtual host. My experiment
environment is Apache2+fastcgi+php-cgi.

I want to implement mass virtual hosting using rewrite rules based on
apache rewrite module. That is, for a request url like:
http://1000.xyz.com/test.php, apache will translate it to a absolute file
path like: $DOCUMENT_ROOT/1000/test.php, and then get this script to
execute.

And my conf is:
*RewriteEngine On*
*RewriteCond %{HTTP_HOST} !^www.xyz.com*
*RewriteCond %{HTTP_HOST} ^([^.]+)\.xyz\.com [NC]*
*RewriteRule (.*) /%1$1 [PT]*
I use inner redirection in order not to expose this detail to users.
Besides, I succeeded when I use external redirection, namely the [R] tag
instead of [PT] tag.
When I use [PT] tag, apache cannot run expectedly. I request a url :
http://1000.xyz.com/test.php, error message pops out like: The requested
URL /1000/cgi-bin/php.fcgi/1000/test.php was not found on this server.

I don't know if this error results from fastcgi, is it the inappropriate
config in fastcgi or inevitable problem by using it?

Really appreciate your help.

Vic

-- 
Best regards,

Rui Hu

State Key Laboratory of Networking  Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: [PHP] PHP page source charset

2011-12-19 Thread Benjamin Hawkes-Lewis
On Tue, Dec 20, 2011 at 2:44 AM, Rick Dwyer rpdw...@earthlink.net wrote:
 When I set my page charset from iso-8859-1 to utf-8

Set it how?

http://www.w3.org/International/O-HTTP-charset.en.php

, when I run it through
 the W3C validator, the validator returns an error that it can't validate the
 page because of an illegal character not covered by UTF-8.


 Sorry, I am unable to validate this document because on line 199 it
 contained one or more bytes that I cannot interpret as utf-8(in other words,
 the bytes found are not valid values in the specified Character Encoding).
 Please check both the content of the file and the character encoding
 indication.
 The error was: utf8 \x99 does not map to Unicode

 Line 199 is a line with my open PHP declaration:
 ?php

 Not sure why W3C is having a hard time with this.  Any ideas?

If you're looking up line references from a W3C validator in your PHP
code, then you're doing something very wrong and are perhaps
fundamentally confused. You need to distinguish between the PHP code
itself and the HTML that it generates and dispatches over the wire to
browsers and validators.

--
Benjamin Hawkes-Lewis

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