php-general Digest 27 Apr 2009 18:20:09 -0000 Issue 6090
Topics (messages 292008 through 292037):
Re: MySQL -- finding whether there's a transaction started
292008 by: Lester Caine
Re: inexplicable behaviour SOLVED
292009 by: Ford, Mike
292016 by: PJ
292027 by: 9el
Re: CamelCase conversion to proper_c_style
292010 by: Richard Heyes
292015 by: Marc Christopher Hall
292017 by: tedd
292019 by: Nathan Rixham
292022 by: Daniel Brown
Re: Help with scandir()
292011 by: Jan G.B.
292014 by: Simon
Green Card Lottery
292012 by: Kylie Gaskins
Re: inexplicable behaviour
292013 by: Simon
utf-8 ?
292018 by: PJ
292020 by: Nathan Rixham
292021 by: 9el
292024 by: PJ
292025 by: 9el
292026 by: Robert Cummings
292028 by: 9el
292029 by: Nathan Rixham
292030 by: Robert Cummings
292031 by: PJ
292032 by: 9el
Variable Scope with require_once
292023 by: user.domain.invalid
Unit Testing
292033 by: Philip Thompson
292035 by: Nathan Rixham
292036 by: Simon
292037 by: Philip Thompson
Re: Formating Numbers
292034 by: Daniel Brown
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Bogdan Stancescu wrote:
Hello list,
I'm developing a library and would need to know if the code calling my
library has already started a MySQL transaction or not. I want to know
whether I should start one or use savepoints instead -- starting a
transaction if one is already in progress commits the existing
transaction, and setting a savepoint silently fails outside
transactions. And I was unable to find any non-destructive way of
retrieving that information -- is there any?
I don't use MySQL, having been embeded with a 'real' database since
before MySQL even thought about transactions ;) but your question does
not make sense from a functional point of view.
The whole point of a transaction is to bundle together a packet of work.
If any part of the packet fails, then it can be rolled back to a known
place. If you are doing a package of work within your library, you would
use your own transaction. If you are processing data for a higher level
function, either that function would pass you the transaction handle, or
IT would handle your return and roll back or carry on as required.
Or am I simply missing something because MySQL still does not ACTUALLY
support real transactions? ( This discussion may be better on the
PHPDatabase list )
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
On 26 April 2009 22:59, PJ advised:
> kranthi wrote:
>> if $Count1 is never referenced after this, then certainly this
>> assignment operation is redundent. but assignment is not the ONLY
>> operation of this statement. if u hav not noticed a post increment
>> operator has been used which will affect the value of $Count as well,
>> and this operation is required for the script to work.
>>
>> the script should work even if u replace
>> $Count1 = $Count++;
>> with
>> $Count++;
>>
>> Kranthi.
>>
>>
> Not quite, since that would change the $Count variable and
> that is used
> leater in the code.
Um -- I must be missing something here, because those two statements
have exactly the same effect on $Count, incrementing it by one (and you
said the first statement fixed your problem, so logically the second one
must too).
In fact, because you've used a post-increment, the statement
$Count1 = $Count++;
ends up with $Count == $Count1+1, and $Count1 being the original value
of $Count!!
This whole scenario smacks to me of a classic "off-by-one" error --
either $Count actually *needs* to be one greater than the value you
first thought of, or some other value you are comparing it to should be
one smaller than it actually is.
Cheers!
Mike
--
Mike Ford, Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus,
Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
Email: [email protected]
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--- End Message ---
--- Begin Message ---
Ford, Mike wrote:
> On 26 April 2009 22:59, PJ advised:
>
>
>> kranthi wrote:
>>
>>> if $Count1 is never referenced after this, then certainly this
>>> assignment operation is redundent. but assignment is not the ONLY
>>> operation of this statement. if u hav not noticed a post increment
>>> operator has been used which will affect the value of $Count as well,
>>> and this operation is required for the script to work.
>>>
>>> the script should work even if u replace
>>> $Count1 = $Count++;
>>> with
>>> $Count++;
>>>
>>> Kranthi.
>>>
>>>
>>>
>> Not quite, since that would change the $Count variable and
>> that is used
>> leater in the code.
>>
>
> Um -- I must be missing something here, because those two statements
> have exactly the same effect on $Count, incrementing it by one (and you
> said the first statement fixed your problem, so logically the second one
> must too).
>
> In fact, because you've used a post-increment, the statement
>
> $Count1 = $Count++;
>
> ends up with $Count == $Count1+1, and $Count1 being the original value
> of $Count!!
>
> This whole scenario smacks to me of a classic "off-by-one" error --
> either $Count actually *needs* to be one greater than the value you
> first thought of, or some other value you are comparing it to should be
> one smaller than it actually is.
>
> Cheers!
>
>
Thanks for the clarification, Mike. In my ignorance, I was under the
impression that the right side of the equation was only for the use of
the left part. How stupid of me. So what I should have been doing was
$Count1 = $Count + 1; right?
Anyway, I don't need that statement anymore as I found the error of my
ways and have corrected it. And behold, the light came forth and it
worked. :-)
> Mike
>
> --
> Mike Ford, Electronic Information Developer,
> C507, Leeds Metropolitan University, Civic Quarter Campus,
> Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
> Email: [email protected]
> Tel: +44 113 812 4730
>
>
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
>
>
--
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
>
> Thanks for the clarification, Mike. In my ignorance, I was under the
> impression that the right side of the equation was only for the use of
> the left part. How stupid of me. So what I should have been doing was
> $Count1 = $Count + 1; right?
>
$Count = $Count + 1; is exactly(?) same as $Count++; or ++$Count
But not exactly same. PostFix notation adds the value after assigning.
PreFix notation adds the value right away.
But optimized programming argues about how machine is coded nowadays.
> Anyway, I don't need that statement anymore as I found the error of my
> ways and have corrected it. And behold, the light came forth and it
> worked. :-)
>
Regards
Lenin
www.twitter.com/nine_L
www.lenin9l.wordpress.com
--- End Message ---
--- Begin Message ---
Hi,
> I know it's probably heresy for a lot of coders, but does anyone know a
> function or class or regexp or somesuch which will scan through a PHP
> file and convert all the CamelCase code into proper C-type code? That
> is, "CamelCase" gets converted to "camel_case". I snagged a bunch of
> someone else's PHP code I'd like to modify, but it's coded the wrong
> way, so I'd like to fix it.
>
> (I'm teasing you CamelCase people. But I really would like to change
> this code around, because it doesn't happen to be my preference.)
I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
--- End Message ---
--- Begin Message ---
My suggestion is to use the Find and Replace feature of your code editing
software. Sorry to disagree with Mr. Hayes, however, if you do as he says
and replace as you go you will be creating errors as these variables,
functions, etc will most likely be CaSe SenSItiVe. Change one then you need
to change all.
As always, do not forget the first three rules of code writing; backup,
backup, backup.
Marc Hall
"The difference between genius and stupidity is that genius has its limits."
*************************************************************************
Hi,
> I know it's probably heresy for a lot of coders, but does anyone know a
> function or class or regexp or somesuch which will scan through a PHP
> file and convert all the CamelCase code into proper C-type code? That
> is, "CamelCase" gets converted to "camel_case". I snagged a bunch of
> someone else's PHP code I'd like to modify, but it's coded the wrong
> way, so I'd like to fix it.
>
> (I'm teasing you CamelCase people. But I really would like to change
> this code around, because it doesn't happen to be my preference.)
I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ Information from ESET Smart Security, version of virus signature
database 4036 (20090427) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--- End Message ---
--- Begin Message ---
At 9:40 AM +0100 4/27/09, Richard Heyes wrote:
Hi,
I know it's probably heresy for a lot of coders, but does anyone know a
function or class or regexp or somesuch which will scan through a PHP
file and convert all the CamelCase code into proper C-type code? That
is, "CamelCase" gets converted to "camel_case". I snagged a bunch of
someone else's PHP code I'd like to modify, but it's coded the wrong
way, so I'd like to fix it.
(I'm teasing you CamelCase people. But I really would like to change
this code around, because it doesn't happen to be my preference.)
I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.
--
Richard Heyes
Not only that. but it you leave each function alone until you work on
it, then you'll have at least some indication of where/when an error
has been introduced.
Many time when I'm using a piece of code that isn't formatted as I
like, I first get it to work as I want changing only the functions
that I must change. After everything is working, I then step through
the code, reformat, and change in small steps.
HTH's
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
tedd wrote:
At 9:40 AM +0100 4/27/09, Richard Heyes wrote:
Hi,
I know it's probably heresy for a lot of coders, but does anyone know a
function or class or regexp or somesuch which will scan through a PHP
file and convert all the CamelCase code into proper C-type code? That
is, "CamelCase" gets converted to "camel_case". I snagged a bunch of
someone else's PHP code I'd like to modify, but it's coded the wrong
way, so I'd like to fix it.
(I'm teasing you CamelCase people. But I really would like to change
this code around, because it doesn't happen to be my preference.)
I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.
--
Richard Heyes
Not only that. but it you leave each function alone until you work on
it, then you'll have at least some indication of where/when an error has
been introduced.
Many time when I'm using a piece of code that isn't formatted as I like,
I first get it to work as I want changing only the functions that I must
change. After everything is working, I then step through the code,
reformat, and change in small steps.
HTH's
tedd
whereas I'd say it shouldn't be a problem to do automatically (but will
be); just only use a tokenizer and not any form of regex or str_replace
etc, that way you can be sure you are ONLY changing classes, methods,
functions, function calls, variables etc
you still may have some problems with any call_user_func or string
references though!
--- End Message ---
--- Begin Message ---
On Mon, Apr 27, 2009 at 01:25, Paul M Foster <[email protected]> wrote:
> I know it's probably heresy for a lot of coders, but does anyone know a
> function or class or regexp or somesuch which will scan through a PHP
> file and convert all the CamelCase code into proper C-type code? That
> is, "CamelCase" gets converted to "camel_case". I snagged a bunch of
> someone else's PHP code I'd like to modify, but it's coded the wrong
> way, so I'd like to fix it.
The other suggestions are more appropriate, of course, but in
direct response to your question, something like this would work
(though I'm typing it in here and it hasn't been tested):
#!/bin/bash
if(test "`which vim`" == ""); then
vi=`which vi`;
else
vi=`which vim`;
fi;
$vi `grep -lRi \$[a-z0-9] *` '+%s/\$\([a-zA-Z0-9_]\)\+/\L&\E/g' '+wn' '+q'
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000
--- End Message ---
--- Begin Message ---
2009/4/26 Nathan Rixham <[email protected]>:
> Deivys Delgado Hernandez wrote:
>>
>> Hi,
>> I'm having problems when i try to use the function scandir() in a Novell
>> Netware Volumen or a Windows Shared Folder
>> they both are mapped as a windows network drive, so i suppose i could
>> access them as local drive, but i can't. instead i receive this message:
>>
>> Warning: scandir(R:\) [function.scandir]: failed to open dir: Invalid
>> argument in C:\WebServ\wwwroot\htdocs\index.php on line 3
>> Warning: scandir() [function.scandir]: (errno 22): Invalid argument in
>> C:\WebServ\wwwroot\htdocs\index.php on line 3
>>
>
> try using the network path instead :) you have to do this for samba drives
> on windows too.
>
> $dir = '//machine.local/share/path';
>
> regards,
>
> nathan
>
> ps: many people just don't answer if they do not know
>
That's quite likely.
Another aproach I thought about when reading your first post was using
"subst" to remap the share as another virtual drive. But I'm unsure if
this would change anything. subst comes with windows and you can map
new drives like that:
subst g: c:\somewhere\else
subst h: b:\
Regards
--- End Message ---
--- Begin Message ---
I lack experience with windows, but my experience in linux tells me
this *might* be related to the permissions the PHP or webserver has to
access that remote drive? Ie. like the drives might be mapped just
for your user?
Not sure, but you might want to check this, permissions are common
problems with using scandir...
Simon
On Mon, Apr 27, 2009 at 4:55 AM, Jan G.B. <[email protected]> wrote:
> 2009/4/26 Nathan Rixham <[email protected]>:
>> Deivys Delgado Hernandez wrote:
>>>
>>> Hi,
>>> I'm having problems when i try to use the function scandir() in a Novell
>>> Netware Volumen or a Windows Shared Folder
>>> they both are mapped as a windows network drive, so i suppose i could
>>> access them as local drive, but i can't. instead i receive this message:
>>>
>>> Warning: scandir(R:\) [function.scandir]: failed to open dir: Invalid
>>> argument in C:\WebServ\wwwroot\htdocs\index.php on line 3
>>> Warning: scandir() [function.scandir]: (errno 22): Invalid argument in
>>> C:\WebServ\wwwroot\htdocs\index.php on line 3
>>>
>>
>> try using the network path instead :) you have to do this for samba drives
>> on windows too.
>>
>> $dir = '//machine.local/share/path';
>>
>> regards,
>>
>> nathan
>>
>> ps: many people just don't answer if they do not know
>>
>
> That's quite likely.
> Another aproach I thought about when reading your first post was using
> "subst" to remap the share as another virtual drive. But I'm unsure if
> this would change anything. subst comes with windows and you can map
> new drives like that:
> subst g: c:\somewhere\else
> subst h: b:\
>
> Regards
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
When Earth was the only inhabited planet in the Galaxy, it was a
primitive place, militarily speaking. The only weapon they had ever
invented worth mentioning was a crude and inefficient nuclear-reaction
bomb for which they had not even developed the logical defense. -
Asimov
--- End Message ---
--- Begin Message ---
Currently, the US Department of Immigration allows 50,000 applications to be
processed for the yearly DV Lottery.
This is just a small number of all the applications they receive every year.
Anyone that has ever previously applied for a chance in the Visa Lottery will
tell you that it's not an easy process.
The biggest problem any person face when it comes to the Green Card Lottery is
the fact that the application must conform perfectly to strict submission
requirements. Even one small mistake can completely disqualify a person from
participating in the US Immigration Lottery.
The Green Card Lottery only happens once a year. Please confirm your interest
at [email protected] to receive further information.
Good luck!
USAGC DV Lottery Services
------------------------------------------------------------------
This email has been written and proved to be in compliance with the recently
established can-spam act law in US. We are not provoking or forcing any person
in any way to participate in our programs. To participate is your own decision
and you carry the responsibility of taking further part in this promotion.
Anyway, if you don't want to receive more good offers from us, you can simply
Unsubscribe by sending us a notification email to [email protected]
with a mail-subject and text "Unsubscribe me", and we will get your email out
of our list within 10 days.
This message is STRICTLY CONFIDENTIAL and is solely for the individual or
organisation to whom it is addressed. It may contain PRIVILEGED and
CONFIDENTIAL information. If you are not the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this communication
and its contents is strictly prohibited. If you are not the intended recipient
you should not read, copy, distribute, disclose or otherwise use the
information in this email. Email may be susceptible to data corruption,
interception and unauthorised amendment, and we do not accept liability for any
such corruption, interception or amendment or the consequences thereof or your
reliance on any information contained therein if you are not the intended
recipient. If you are not interested in the offered promotions, please just
don't answer. If you think you have received this message and its contents in
error, please delete it from your computer, or follow the unsubscribing
procedure shown above.
------------------------------------------------------------------
--- End Message ---
--- Begin Message ---
If you want to increment $Count by one, you can use any one of the 3
following lines to do this:
$Count = $Count + 1;
$Count += 1;
$Count++;
The 3 lines are equivalent, but have varying degrees of elegance (suit
yourself). However, make sure that your mysql function returned a
number (and not an error message or whatever else).
It's also possible the 'next' redirection isnt working because the
value in $Count is invalid somehow? doesnt point to any page or
something like that?
Simon
On Fri, Apr 24, 2009 at 8:14 PM, PJ <[email protected]> wrote:
> Frankly, I don't know what to look for or why something so weird would
> happen:
> I have pagination set up and the number for pages "next" has a link but
> the "next" does not. I have experimented with all sorts of
> configurations of the code but the only thing that works (and this is
> totally "off the wall") is to do this
> $Count = mysql_num_rows($results);
> $Count1=$Count++; // without this, the "next" does not do the link---
> but there is no other $Count1 in the code either in the original page or
> the include page.
> And this phenomenon was apparent in a similar page.
> I'd be curious to understand how this could happen. I could post the
> whole code, but that would be some 300 lines...
>
> --
> unheralded genius: "A clean desk is the sign of a dull mind. "
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
> http://www.ptahhotep.com
> http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Since I have to use a number of Western languages that have those
annoying accents on many characters, I am already finding some
annoyances in my code results; like having to enter the á type of
stuff in inputs for searches & queries.
MySql db is set up for InnoDB with latin1_swedish_ci for Collation; I
believe this is default.
Utf-8 seems to be one way to overcome the problems, but is it the only
way - seems a little cumbersome as I have no need for oriental & other
extra-terrestrial cyphers. (I'm incorrigibly lazy.)
If it is the only way, what difficulties could I expect from an ISP
hosting a virtual site?
--
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
PJ wrote:
Since I have to use a number of Western languages that have those
annoying accents on many characters, I am already finding some
annoyances in my code results; like having to enter the á type of
stuff in inputs for searches & queries.
MySql db is set up for InnoDB with latin1_swedish_ci for Collation; I
believe this is default.
in that case you'd have to convert all your databases to utf8 /
utf_general_ci
Utf-8 seems to be one way to overcome the problems, but is it the only
way - seems a little cumbersome as I have no need for oriental & other
extra-terrestrial cyphers. (I'm incorrigibly lazy.)
can't think of any good reason why you shouldn't be using utf-8..
If it is the only way, what difficulties could I expect from an ISP
hosting a virtual site?
none really AFAIK - but converting all your latin1 to utf-8 will be a
very fun job indeed!
--- End Message ---
--- Begin Message ---
I think you should switch to utf8-general-ci all the way.
--- End Message ---
--- Begin Message ---
Nathan Rixham wrote:
> PJ wrote:
>> Since I have to use a number of Western languages that have those
>> annoying accents on many characters, I am already finding some
>> annoyances in my code results; like having to enter the á type of
>> stuff in inputs for searches & queries.
>> MySql db is set up for InnoDB with latin1_swedish_ci for Collation; I
>> believe this is default.
>
> in that case you'd have to convert all your databases to utf8 /
> utf_general_ci
>
>> Utf-8 seems to be one way to overcome the problems, but is it the only
>> way - seems a little cumbersome as I have no need for oriental & other
>> extra-terrestrial cyphers. (I'm incorrigibly lazy.)
>
> can't think of any good reason why you shouldn't be using utf-8..
>
>> If it is the only way, what difficulties could I expect from an ISP
>> hosting a virtual site?
>
> none really AFAIK - but converting all your latin1 to utf-8 will be a
> very fun job indeed!
>
I looked at http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
which suggests this:
ALTER DATABASE db_name
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci
;
ALTER TABLE tbl_name
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
;
or I could do it with phpMyAdmin, right?
and the only difficulties would appear to be fixing any accent stuff
(don't know yet just what) and that would only be time consuming.
I guess I'm just looking for reassurance that I don't muck up anything
and then have to do tortured acrobatics to redress things again. :-)
--
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
> I looked at http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
> which suggests this:
> ALTER DATABASE db_name
> CHARACTER SET utf8
> DEFAULT CHARACTER SET utf8
> COLLATE utf8_general_ci
> DEFAULT COLLATE utf8_general_ci
> ;
>
> ALTER TABLE tbl_name
> DEFAULT CHARACTER SET utf8
> COLLATE utf8_general_ci
> ;
>
> or I could do it with phpMyAdmin, right?
>
> and the only difficulties would appear to be fixing any accent stuff
> (don't know yet just what) and that would only be time consuming.
>
> I guess I'm just looking for reassurance that I don't muck up anything
> and then have to do tortured acrobatics to redress things again. :-)
>
> Changing to UTF8 is time consuming but if programming can be used it would
ease the effort. I have seen a WP plugin for that as well. And in phpmyAdmin
you'll have to set the collation for all fields and tables one by one. :)
Regards
Lenin
www.twitter.com/nine_L
--- End Message ---
--- Begin Message ---
On Mon, 2009-04-27 at 20:56 +0600, 9el wrote:
> > I looked at http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
> > which suggests this:
> > ALTER DATABASE db_name
> > CHARACTER SET utf8
> > DEFAULT CHARACTER SET utf8
> > COLLATE utf8_general_ci
> > DEFAULT COLLATE utf8_general_ci
> > ;
> >
> > ALTER TABLE tbl_name
> > DEFAULT CHARACTER SET utf8
> > COLLATE utf8_general_ci
> > ;
> >
> > or I could do it with phpMyAdmin, right?
> >
> > and the only difficulties would appear to be fixing any accent stuff
> > (don't know yet just what) and that would only be time consuming.
> >
> > I guess I'm just looking for reassurance that I don't muck up anything
> > and then have to do tortured acrobatics to redress things again. :-)
> >
> > Changing to UTF8 is time consuming but if programming can be used it would
> ease the effort. I have seen a WP plugin for that as well. And in phpmyAdmin
> you'll have to set the collation for all fields and tables one by one. :)
I think some time ago I used combination of mysqldump and iconv, some
minor editing, and then pumped it back into the database.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
>
>
> I think some time ago I used combination of mysqldump and iconv, some
> minor editing, and then pumped it back into the database.
>
> I think if the dump is not too big your trick will yield good results.
What do you do for really large DB cases?
Regards
Lenin
www.twitter.com/nine_L
www.lenin9l.wordpress.com
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Mon, 2009-04-27 at 20:56 +0600, 9el wrote:
I looked at http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
which suggests this:
ALTER DATABASE db_name
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci
;
ALTER TABLE tbl_name
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
;
or I could do it with phpMyAdmin, right?
and the only difficulties would appear to be fixing any accent stuff
(don't know yet just what) and that would only be time consuming.
I guess I'm just looking for reassurance that I don't muck up anything
and then have to do tortured acrobatics to redress things again. :-)
Changing to UTF8 is time consuming but if programming can be used it would
ease the effort. I have seen a WP plugin for that as well. And in phpmyAdmin
you'll have to set the collation for all fields and tables one by one. :)
I think some time ago I used combination of mysqldump and iconv, some
minor editing, and then pumped it back into the database.
Cheers,
Rob.
snap;
also utf8_decode and utf8_encode
I'm also sure there's a way to do it using by setting the client
connection char set and server char set to do an auto conversion..
--- End Message ---
--- Begin Message ---
On Mon, 2009-04-27 at 21:06 +0600, 9el wrote:
>
> I think some time ago I used combination of mysqldump and
> iconv, some
> minor editing, and then pumped it back into the database.
>
> I think if the dump is not too big your trick will yield good results.
> What do you do for really large DB cases?
I haven't had the displeasure :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
9el wrote:
>
> I looked at http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
> which suggests this:
> ALTER DATABASE db_name
> CHARACTER SET utf8
> DEFAULT CHARACTER SET utf8
> COLLATE utf8_general_ci
> DEFAULT COLLATE utf8_general_ci
> ;
>
> ALTER TABLE tbl_name
> DEFAULT CHARACTER SET utf8
> COLLATE utf8_general_ci
> ;
>
> or I could do it with phpMyAdmin, right?
>
> and the only difficulties would appear to be fixing any accent stuff
> (don't know yet just what) and that would only be time consuming.
>
> I guess I'm just looking for reassurance that I don't muck up anything
> and then have to do tortured acrobatics to redress things again. :-)
>
> Changing to UTF8 is time consuming but if programming can be used it
> would ease the effort. I have seen a WP plugin for that as well. And
> in phpmyAdmin you'll have to set the collation for all fields and
> tables one by one. :)
>
> Regards
>
> Lenin
>
> www.twitter.com/nine_L <http://www.twitter.com/nine_L>
I just converted all, or thought I did.
phpMyAdmin: in the structure view of the db show Collation as
latin_swedish_ci ???
in the individual table structure views the fields show utf-8 general ???
I don't see any difference on Firefox running on FreeBSD but it show
correctly on Wimpy XP ??. In the web page the accent for French shows as
a ? within a white diamond on FBSD.
In the database the entry is the French chatacter with the accent.
I'm now trying to figure out how to enter the accents on FBSD in
Firefox. Nuts! This is torcher.
How does one become truly international?
--
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
>
>
> I just converted all, or thought I did.
> phpMyAdmin: in the structure view of the db show Collation as
> latin_swedish_ci ???
> in the individual table structure views the fields show utf-8 general ???
> I don't see any difference on Firefox running on FreeBSD but it show
> correctly on Wimpy XP ??. In the web page the accent for French shows as
> a ? within a white diamond on FBSD.
> In the database the entry is the French chatacter with the accent.
> I'm now trying to figure out how to enter the accents on FBSD in
> Firefox. Nuts! This is torcher.
> How does one become truly international?
>
Without much argument you should just follow What Robert has told
Just dump your db and you can replace the collate to desired one and then
put back in DB server et voila!
--- End Message ---
--- Begin Message ---
Hello, all.
I have a working app that runs in PHP 4.4.9 on the server. I develop
the app on my local environment, which runs PHP 5.2.6.
The setup is thus:
From my index, I have
require_once('config.php');
require_once('dbstuff.php');
config.php looks like this:
<?php
$db_host = 'localhost';
$db_user = 'someuser';
$db_password = 'somepassword';
$
...snipped...
?>
dbstuff.php looks like this:
<?php
if( !$dbh ) {
$dbh = mysql_connect($db_host, $db_user, $db_password) or die('Could
not connect: ' . mysql_error());
}
...snipped...
?>
For some reason, the $db_host, $db_user, and so on defined in config.php
are not accessible from dbstuff.php on my development environment. I
wlll get
[timestamp] [error] [client 127.0.0.1] PHP Notice: Undefined variable:
db_host in somepath\db_stuff.php on line whatever
which causes
'Could not connect: some MySQL error message that is obtained when
attempting to login with a nonexistent user'
This works on the production environment (the one with PHP version
4.4.9). register_globals is Off in both environments.
What is going on, here?
Regards,
A. Wilson
--- End Message ---
--- Begin Message ---
Hi. I did some searching in the archives, but didn't quite find what I
was looking for. Maybe a few of you can assist me...
We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing early on
because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is..... is it reasonable to
start unit testing at this point in time with the application mostly
built? Besides being really time-consuming, what are the pitfalls of
starting unit testing at this stage?
Thanks in advance,
~Philip
--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
Hi. I did some searching in the archives, but didn't quite find what I
was looking for. Maybe a few of you can assist me...
We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing early on
because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is..... is it reasonable to start
unit testing at this point in time with the application mostly built?
Besides being really time-consuming, what are the pitfalls of starting
unit testing at this stage?
Thanks in advance,
~Philip
maybe a useless answer, but, no pitfalls - just do it - I'm always
surprised by my unit test results, its invaluable and it's never too
late to start.
just think about the next years worth of bugs found by the client not
being there!
--- End Message ---
--- Begin Message ---
As a programmer, i always test what I'm coding as i code it (mostly to
make sure i dont include typos), but i feel it is best to make proper
testing once the component is ready and working fine. If your project
is large, it might be a good idea to break it in several 'modules' or
section if possible and treat each of them as separate projects
(testing would be done on a module once this one is ready).
You may be interested in looking for information on the net on 'IT
project management' which usually describe when is the best time to
test according to a certain structure...
Simon
On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham <[email protected]> wrote:
> Philip Thompson wrote:
>>
>> Hi. I did some searching in the archives, but didn't quite find what I was
>> looking for. Maybe a few of you can assist me...
>>
>> We have an application that's currently in production, but we're
>> constantly modifying/upgrading it. We did not do unit testing early on
>> because of the lack of time. Now that some time has opened up, we're
>> considering unit testing. My question is..... is it reasonable to start unit
>> testing at this point in time with the application mostly built? Besides
>> being really time-consuming, what are the pitfalls of starting unit testing
>> at this stage?
>>
>> Thanks in advance,
>> ~Philip
>
> maybe a useless answer, but, no pitfalls - just do it - I'm always surprised
> by my unit test results, its invaluable and it's never too late to start.
>
> just think about the next years worth of bugs found by the client not being
> there!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
When Earth was the only inhabited planet in the Galaxy, it was a
primitive place, militarily speaking. The only weapon they had ever
invented worth mentioning was a crude and inefficient nuclear-reaction
bomb for which they had not even developed the logical defense. -
Asimov
--- End Message ---
--- Begin Message ---
On Apr 27, 2009, at 11:38 AM, Simon wrote:
As a programmer, i always test what I'm coding as i code it (mostly to
make sure i dont include typos), but i feel it is best to make proper
testing once the component is ready and working fine. If your project
is large, it might be a good idea to break it in several 'modules' or
section if possible and treat each of them as separate projects
(testing would be done on a module once this one is ready).
You may be interested in looking for information on the net on 'IT
project management' which usually describe when is the best time to
test according to a certain structure...
Simon
On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham <[email protected]>
wrote:
Philip Thompson wrote:
Hi. I did some searching in the archives, but didn't quite find
what I was
looking for. Maybe a few of you can assist me...
We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing
early on
because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is..... is it reasonable to
start unit
testing at this point in time with the application mostly built?
Besides
being really time-consuming, what are the pitfalls of starting
unit testing
at this stage?
Thanks in advance,
~Philip
maybe a useless answer, but, no pitfalls - just do it - I'm always
surprised
by my unit test results, its invaluable and it's never too late to
start.
just think about the next years worth of bugs found by the client
not being
there!
A question I have about unit testing. The point is to test individual
"units"... correct? So, let's say I have this core class which creates
instances of other classes. Well, if I only want test the core class,
I don't want to instantiate the other classes... correct? Example:
<?php
// Core.php
require ('Class1.php');
require ('Class2.php');
class Core {
public function __construct () {
$this->class1 = new Class1 ($this);
$this->class2 = new Class2 ($this);
}
}
// CoreTest.php
require ('../PHPUnit/Framework.php');
require ('../includes/Core.php');
class CoreTest extends PHPUnit_Framework_TestCase {
protected function setUp () {
$this->core = new Core();
}
}
?>
So, here, Class1 and Class2 will be instantiated. However, I don't
really care for them to be so that I can test all the methods in the
core class. Is this a perfect example of how the original design of
the core class is not conducive to implementing unit tests? Without
rewriting the core class, is there a way to test this?
Thanks,
~Philip
--- End Message ---
--- Begin Message ---
On Sun, Apr 26, 2009 at 18:15, Gary <[email protected]> wrote:
> Sorry for the delay in response. I was able to figure the number_format()
> function out.
>
> Thanks for all your responses.
Since you're working specifically with money as described in your
example, Gary, you could also check out money_format()[1] and should
have a brief overview of the optional locale settings such as
setlocale()[2] for working with code created by others.
Now get outside. You're somewhere down the road from me, and it's
87F and sunny out here right now. ;-P
KEY:
^1: http://php.net/money_format
^2: http://php.net/setlocale
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000
--- End Message ---