Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to change PHP4 code to PHP5?
Old 09-25-2007, 01:15 AM How to change PHP4 code to PHP5?
Skilled Talker

Posts: 79
Name: Liu King
Trades: 0
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?
mcooce is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-25-2007, 02:11 AM Re: How to change PHP4 code to PHP5?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
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.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 09-25-2007, 03:07 AM Re: How to change PHP4 code to PHP5?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Originally Posted by vangogh View Post
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
Quote:
MySQL Server Error:
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 04:01 PM Re: How to change PHP4 code to PHP5?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
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.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 09-25-2007, 04:19 PM Re: How to change PHP4 code to PHP5?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 04:22 PM Re: How to change PHP4 code to PHP5?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-25-2007, 04:23 PM Re: How to change PHP4 code to PHP5?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
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.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 09-25-2007, 04:29 PM Re: How to change PHP4 code to PHP5?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 05:57 PM Re: How to change PHP4 code to PHP5?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-25-2007, 07:30 PM Re: How to change PHP4 code to PHP5?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by tripy View Post
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-25-2007, 07:34 PM Re: How to change PHP4 code to PHP5?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 07:54 PM Re: How to change PHP4 code to PHP5?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to How to change PHP4 code to PHP5?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34679 seconds with 12 queries