How to change PHP4 code to PHP5?
09-25-2007, 01:15 AM
|
How to change PHP4 code to PHP5?
|
Posts: 78
Name: Liu King
|
PHP4 code is differ from PHP5.
When i test the script,i say:
MySQL Server Error:
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation '='
Then how to change PHP4 code to PHP5?
|
|
|
|
09-25-2007, 02:11 AM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 8,370
Name: Steven Bradley
Location: Boulder, Colorado
|
Wouldn't that be an error in the MySQL and not the PHP?
We'll need to see your PHP code in order to help with PHP issues.
|
|
|
|
09-25-2007, 03:07 AM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 1,822
Name: Thierry
Location: In the void
|
Quote:
Originally Posted by vangogh
Wouldn't that be an error in the MySQL and not the PHP?
We'll need to see your PHP code in order to help with PHP issues.
|
Well, as the error says
I'm fairly certain that your problem is with mysql, and not php.
Php5 in 99% compatible with php4.
In the last 3 years, I've only seen 1 case where adaptation where needed, and it was 1 line to correct in a 200+ pages site.
But mysql, on the other side, is way more prone to errors like that if you upgraded from mysql4 to mysql5.
Mysql4 was totally loose, and "error" compliant. It allowed many idiocracy that where removed in the mysql5 rewrite.
you're problem probably lies there.
__________________
Listen to the ducky: "This is awesome!!!"
|
|
|
|
09-25-2007, 04:01 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 8,370
Name: Steven Bradley
Location: Boulder, Colorado
|
That was kind of my thinking too Thierry. I figure when it says MySQL error it's probably an error in MySQL. I was wondering if the upgrade from 4 to 5 was really in the database.
That's interesting that you haven't seen problems with the PHP upgrade. I've been led to believe it could break a few things, which I'm sure in some cases it does, but I haven't seen many issues myself either. I assume it comes down to using good coding practices.
|
|
|
|
09-25-2007, 04:19 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 1,822
Name: Thierry
Location: In the void
|
Sorry Steven, I know that you are well educated in that field.
I just wanted to point that an upgrade from php4 to php5 is completely independent from the mysql4 to mysql5 update, and that if both where upgraded, the problem was surely there.
About php4 to 5, well, yeah, good coding practice surely have helped.
I ever coded the best I could, and never just copy/pasted some random code found on the web.
At worst, I had rewrote it to integrate into my libraries.
Now that I think of it, I remember that squirrelMail (a popular php imap web frontend) had problem with php5 at the beginning.
But I believe it was solved after 2 weeks....
Really, for what I've seen, all the big and popular applications written in php have fairly quickly migrated their code to be compatible php5, even if they where not leveraging the advantages of php5 for compatibility reasons.
__________________
Listen to the ducky: "This is awesome!!!"
|
|
|
|
09-25-2007, 04:22 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 467
Name: Matt
Location: Irvine, CA
|
The biggest problem I've had with compatibility between PHP 4 and 5 is with OOP (object oriented programming) so unless you're creating classes you're problem is probably not with PHP. Like everyone else said, it looks like a SQL error.
|
|
|
|
09-25-2007, 04:23 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 8,370
Name: Steven Bradley
Location: Boulder, Colorado
|
No need to apologize. I didn't take any offense and I'm always happy for someone to make things clearer than I left them.
I'm familiar with SquirrelMail. I have it through cPanel and have used it on very rare occasions. With the lack of problems it makes you wonder why more hosts haven't upgraded to PHP 5 yet. I think vesion 4 is still the de facto in use.
|
|
|
|
09-25-2007, 04:29 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 1,822
Name: Thierry
Location: In the void
|
Matt, I'm curious about your problem...
I've coded the "barebone" of my sites for the last 5 years in oop, and usually with smarty.
The only problem I've faced when going from php4 to php5 was in the case I was doing a reference passed method call, that worked in php4 but was depreciated in php5 (I believe, not sure anymore...)
Otherwise, everything that was php4 oop compliant is still valid today, if you don't mind the "notices" the engine sends you about the new properties and method declarations...
__________________
Listen to the ducky: "This is awesome!!!"
|
|
|
|
09-25-2007, 05:57 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 5,805
Name: Dan
Location: Swindon
|
He has asked this in another thread and was told that it was MySQL and he should make all of them the same
and pick latin1_swedish_ci OR gbk_chinese_ci,COERCIBLE
Am i right that this should fix the error?
__________________
Personal UK Webhosting Get 25% of ANY shared package for life ~ Promo: webmaster-talk
|
|
|
|
09-25-2007, 07:30 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 467
Name: Matt
Location: Irvine, CA
|
Quote:
Originally Posted by tripy
Matt, I'm curious about your problem...
I've coded the "barebone" of my sites for the last 5 years in oop, and usually with smarty.
The only problem I've faced when going from php4 to php5 was in the case I was doing a reference passed method call, that worked in php4 but was depreciated in php5 (I believe, not sure anymore...)
Otherwise, everything that was php4 oop compliant is still valid today, if you don't mind the "notices" the engine sends you about the new properties and method declarations...
|
I havn't had problems going from 4 to 5. But the object model in php 5 has a ton of new features, so it's difficult going from 5 to 4. I coded a facebook app for a friend and the api relies heavily on oop and refused to work on his server because it was PHP4.
I'm a java/c++ coder primarily so I prefer the PHP5 object model (not declaring visibilty drives me insane). Honestly I wouldn't mind if PHP required datatype declaration.
|
|
|
|
09-25-2007, 07:34 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 1,822
Name: Thierry
Location: In the void
|
Ok, I understand.
Yes, there where so much enhancements in php5 related to oop, that I believe you when you said it was a mess downgrading from 5 to 4.
I was talking about descending compatibility here. How php5 handled php4 code.
I'd like too PHP being a more typed language, but I truly think that it's his loose types that makes him so easy to learn.
After that, it's just about good practice to declare your variables in your header. True, it don't avoid implicit conversions, but you can use === to check your types...
What I lack the most personally, is the signatures on the methods...
__________________
Listen to the ducky: "This is awesome!!!"
|
|
|
|
09-25-2007, 07:54 PM
|
Re: How to change PHP4 code to PHP5?
|
Posts: 467
Name: Matt
Location: Irvine, CA
|
Yes that's been a problem for me too, but I don't think it is possible (or reasonable) to allow for function overloading by input type without type checking.
I found a plugin that allows for PHP to instantiate java classes (this would make me very happy if it were installed by default) but I'm unsure of its performance, I prefer more java like code but not at the expense of a reasonable execution time.
|
|
|
|
|
« Reply to How to change PHP4 code to PHP5?
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|