This code works on it's own, but not in a HTML website why?

[php] <?php
// Create connection
$con=mysqli_connect(“localhost:3307”,“root”,“usbw”,“fut”);

// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

//run a simple select statement
$result = mysqli_query($con,“SELECT Cost FROM cards WHERE PlayerID = 2”);

//output the results to the page
while($row = mysqli_fetch_array($result))
{
echo $row[‘Cost’];
echo “
”;
}

//close the connection
mysqli_close($con);
?> [/php]

If you mean a file with a .html extension then you have to set up your web server to send .html files (as well as .php) to PHP. Or you can just change the extension to .php (which is what you probably want to do)

Sponsor our Newsletter | Privacy Policy | Terms of Service