Jump to content

Embedding a php snippet onto the site


KrypTarch

Recommended Posts

As the title says how would i go by doing that, because i set up a php block and tried using it with the custom blocks feature and it does not work

right now this is what i haven done in my custom block obviously above is my db details f9d73ee4ca.png

Link to comment
Share on other sites

Custom PHP blocks work fine, I'm working on several right now.  If you have ANY error in syntax you will get nothing though. 

If you can check the block with just a print statement to eliminate any other issue, you are then down to your php code being the issue.

For instance if that is a double quote at the start of your while echo, you'll get nothing most likely.

Link to comment
Share on other sites

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed to AuXile Framework Highscores Database: " . $conn->connect_error);
} 

$sql = "SELECT name, locker FROM account ORDER BY locker DESC LIMIT 5";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Name: " . $row["name"]. " - $: " . $row["locker"]. ";
    }
} else {
    echo ''Error fecthing any players from database.'';
}
$conn->close();

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...