Displaying records from my database

I’m new to PHP, I’ve made a connection to the database at the top of the page, it’s simple I just want to show the Cost of the second player in my table Cards, the issue is that nothing is displayed at all on my page

[php]<?php

	$query = "SELECT Cost FROM cards where PlayerID = 2";

if ($result = mysqli_query($con, $query)) {

/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
    echo ($row["Cost"]);

}
}
?>[/php]

One thing, it is echo ; not echo ();

Next, add these lines to the top on NON PRODUCTION pages:
[php]error_reporting(E_ALL);
ini_set(‘display_errors’, 1);[/php]

Lastly,
[php]
try {

// your database code

} catch ( Exception $e ) {
echo $e->getMessage();
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service