Updating php
Updating php
Hey, I have a question which confuses me alot. If I make a game or website and then there is a php update, should I update it ? If yes then how, and lastly what about my code? What if new php require me to change most of my code, is it worth it ? I am asking that because when I try to follow tutorial for browser mmorpg(old one) its out of date, so I have to either use old php or I cant follow this tutorial unless I know how to update whole code. First thing I had a problem with was connecting to database If I remember correctly, because code has changed with new php. I hope you understand my question and could help me
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Updating php
Remember that what you are updating with PHP is the runtime engine. So your code can stay just like it was, but the Apache module or stand alone module for PHP is updated.
Breaking changes are fairly rare with PHP these days. Earlier on in PHP's life, there were some major upheavals, such as PHP 3 to PHP 4, and a huge shift from PHP 4 to 5. There were some small breaking changes and deprecations in the early versions of PHP 5, such as 5.0 to 5.1, but ever since then PHP has really stabilized. The last 2 minor versions updates have not broken anything to my knowledge.
It is very possible when you go and find old code online that doesn't work right today, it was likely PHP 4 or PHP 5.0, both of which would have some problems today. If it was just broken all over the place (like Dragon Knight), it is PHP 4, which is over 10 years old now at this point.
All that said, you don't have to update PHP. There are security fixes in most releases, although they are of variable urgency. Quite often they do release bug patches for important security problems for users who cannot update their whole PHP version for one reason or another. But if you are not planning on updating your application to make use of new features and there aren't any security patches you need, you really don't need to update.
Breaking changes are fairly rare with PHP these days. Earlier on in PHP's life, there were some major upheavals, such as PHP 3 to PHP 4, and a huge shift from PHP 4 to 5. There were some small breaking changes and deprecations in the early versions of PHP 5, such as 5.0 to 5.1, but ever since then PHP has really stabilized. The last 2 minor versions updates have not broken anything to my knowledge.
It is very possible when you go and find old code online that doesn't work right today, it was likely PHP 4 or PHP 5.0, both of which would have some problems today. If it was just broken all over the place (like Dragon Knight), it is PHP 4, which is over 10 years old now at this point.
All that said, you don't have to update PHP. There are security fixes in most releases, although they are of variable urgency. Quite often they do release bug patches for important security problems for users who cannot update their whole PHP version for one reason or another. But if you are not planning on updating your application to make use of new features and there aren't any security patches you need, you really don't need to update.
The indelible lord of tl;dr
Re: Updating php
Thanks, I guess its like you said, code I am reading right now must be from old php:
http://indie-resource.com/forums/viewforum.php?f=33
Thanks for the answer
http://indie-resource.com/forums/viewforum.php?f=33
Thanks for the answer
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Updating php
The browser MMO code is all compatible with modern PHP engines. I would assume there is a code error somewhere.
The indelible lord of tl;dr
Re: Updating php
Second video where you connect to database, didnt work for me. I will check it later and give you more details, maybe then you can help me out more.
@edit:
I guess you were right, everything seems to be working now, I have no idea what kind of mistake I have done before, thanks for the answer.
@edit:
I guess you were right, everything seems to be working now, I have no idea what kind of mistake I have done before, thanks for the answer.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Updating php
No problem
There are a lot of small errors that can be in database connection code, from errors in the username, password, the database user, and then of course the actual code to make the connection. Glad you got it working, though!
There are a lot of small errors that can be in database connection code, from errors in the username, password, the database user, and then of course the actual code to make the connection. Glad you got it working, though!
The indelible lord of tl;dr
Re: Updating php
It's not hard to switch Halls mysql over to mysqli instead of mysql, since mysql is outdated. Here's an example:
MYSQL
MYSQLI
Example of your $db_conx, which is u're database connection. You can name it anything as long as they match.
MYSQL
Code: Select all
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
Code: Select all
$playerinfo = "SELECT * FROM players WHERE name='$player'";
$playerinfo2 = mysqli_query($db_conx, $playerinfo);
$playerinfo3 = mysqli_fetch_array($playerinfo2, MYSQLI_ASSOC);
Example of your $db_conx, which is u're database connection. You can name it anything as long as they match.
Code: Select all
<?php
$db_conx = mysqli_connect("localhost", "root", "", "login2");
// Evaluate the connection
if (mysqli_connect_errno()) {
echo mysqli_connect_error();
exit();
}// else {
//echo "Successful database connection!!!";
//}
?>
Re: Updating php
Thanks Epiales, that was the problem I had before.
Re: Updating php
No worries, if you need anything just ask, Everyone is very helpfultarnos12 wrote:Thanks Epiales, that was the problem I had before.