Updating php

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.

Updating php

Postby tarnos12 » Wed Oct 15, 2014 3:50 pm

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 :)
tarnos12
 
Posts: 16
Joined: Thu Dec 26, 2013 7:42 am
Location: Poland
Has thanked: 2 times
Been thanked: 0 time

Re: Updating php

Postby Jackolantern » Wed Oct 15, 2014 5:54 pm

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.
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10893
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 92 times
Blog: View Blog (1)

Re: Updating php

Postby tarnos12 » Wed Oct 15, 2014 7:15 pm

Thanks, I guess its like you said, code I am reading right now must be from old php:

viewforum.php?f=33

Thanks for the answer :)
tarnos12
 
Posts: 16
Joined: Thu Dec 26, 2013 7:42 am
Location: Poland
Has thanked: 2 times
Been thanked: 0 time

Re: Updating php

Postby Jackolantern » Wed Oct 15, 2014 7:25 pm

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
User avatar
Jackolantern
 
Posts: 10893
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 92 times
Blog: View Blog (1)

Re: Updating php

Postby tarnos12 » Wed Oct 15, 2014 7:51 pm

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.
tarnos12
 
Posts: 16
Joined: Thu Dec 26, 2013 7:42 am
Location: Poland
Has thanked: 2 times
Been thanked: 0 time

Re: Updating php

Postby Jackolantern » Thu Oct 16, 2014 9:59 am

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!
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10893
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 92 times
Blog: View Blog (1)

Re: Updating php

Postby Epiales » Thu Oct 16, 2014 10:59 am

It's not hard to switch Halls mysql over to mysqli instead of mysql, since mysql is outdated. Here's an example:

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); 


MYSQLI

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!!!";
//}
?>
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: Updating php

Postby tarnos12 » Thu Oct 16, 2014 11:37 am

Thanks Epiales, that was the problem I had before.
tarnos12
 
Posts: 16
Joined: Thu Dec 26, 2013 7:42 am
Location: Poland
Has thanked: 2 times
Been thanked: 0 time

Re: Updating php

Postby Epiales » Thu Oct 16, 2014 11:39 am

tarnos12 wrote:Thanks Epiales, that was the problem I had before.


No worries, if you need anything just ask, Everyone is very helpful :)
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times


Return to Beginner Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x