I have created a highscore script (takes data from a java game).
So this is the script I used to take the value for each row, for example this row will be called 'player name':
<td style="padding:3px;" align="center">
<?php
$con = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(MYSQL_DATABASE, $con);
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo $row['playerName'];
echo "<br />";
}
mysql_close($con);
?>
</td>
And I have 4 more scripts like this under each other. How do I open just one connection instead of open & closing connection everytime?
Thanks!
mysql_*FUNCTIONS. This extension is old and deprecated and due to be removed from PHP. Use PDO or MYSQLI instead.