Having trouble connecting mysqli with database

Not sure where the error is. But I’m not getting anythign back from my database. I’m looking through it all but I don’t recieve any error in the syntax. I’m wondering why none of the data is echoing out. Can someone please help with this?

Here’s the dbconnect file :

<?php

//Connect to the MySQL Server "hostname", "username", "password" or
//if there was a problem connect die with an error
$connection = mysqli_connect("db760589391.hosting-data.io", "dbo760589391", "-------X");

if( $connection == false){
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
//Select the database we want to use
mysqli_select_db($connection, "db760589391");

?>

and here is the php.file

	<?php

	require("dbconnect.php");
	
	
	$sql = "SELECT * FROM product";
	$results = mysqli_query($connection, $sql);
	$count = 0; // Initialize  count
	
	while($myrow = mysqli_fetch_array($connection, $results)) {
			//display catalog items
			
			$image_sm = $myrow['image_sm'];
			$id = $myrow['id'];
			$name = $myrow['name'];
			$price = $myrow['price'];
			$desc_short = $myrow['desc_short'];
			$reviews = $myrow['reviews'];
			$rating = round($myrow ['rating'], 2);
			
			echo "<div class='item'>
							<a href='product_detail.php?cat_id=$id'>
									<img src='images/$image_sm'/>
									<p> Name:$name Price:\$$price</p>
									<p>$desc_short</p>
									<p>Reviews:$reviews rating:$rating</p>
							</a>
									</div>\n";
									
			if (($count % 2) == 2) {
					echo "<hr/>";
			}
	}
	mysqli_close($connection);

?>

Is there definitely data in the table?

Are errors turned on for you to see if there is an issue? Have you looked in the error log to see if anything is showing there?

Sponsor our Newsletter | Privacy Policy | Terms of Service