Deprecated: mysql_connect(): The mysql extension is deprecated and wil
Posted 4 minutes ago
I have created a php rating system for my website. It has been working fine, i have started up the mamp program and i am now getting this error message:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /Applications/MAMP/htdocs/project1/rate.php on line 3
I have tried several things for it to work but i have had no luck, i have changed the php.ini file error option; display_errors = On to display_errors = Off. I have had no luck please help i have been stuck all evening on this. Thank you in advance.
The two pages which involves this error are below:
The php code for the fglrank.php page is:
<?php mysql_connect("localhost","root","root") or die ("Couldnt connect to server"); mysql_select_db("rating") or die ("Couldnt connect to database"); $find_data = mysql_query("SELECT * FROM rates"); while($row = mysql_fetch_assoc($find_data)) { $id = $row['id']; $name_of_player = $row['nameofplayer']; $pos = $row['pos']; $current_rating = $row['rating']; $hits = $row['hits']; echo " $name_of_player: 1 2 3 4 5 6 7 8 9 10 Current Rating: "; echo round($current_rating, 2); echo " "; } ?>The rate.php file code is:
<?php mysql_connect("localhost","root","root") or die ("Couldnt connect to server"); mysql_select_db("rating") or die ("Couldnt connect to database"); $pos = $_POST['pos']; $post_rating = $_POST['rating']; $find_data = mysql_query("SELECT * FROM rates WHERE pos='$pos'"); while($row = mysql_fetch_assoc($find_data)) { $id = $row['id']; $current_rating = $row['rating']; $current_hits = $row['hits']; } $new_hits = $current_hits + 1; $update_hits = mysql_query("UPDATE rates SET hits = '$new_hits' WHERE id='$id'"); $pre_rating = $current_rating + $post_rating; $new_rating = $pre_rating / $new_hits; $update_rating = mysql_query("UPDATE rates SET rating = '$new_rating' WHERE id='$id'"); ?>