Cannot get data to load from a table

I would really appreciate help with an issue I am having. I had a server that self-destructed with Unbutu and LAMP. I had to rebuild it and am now using PHP 7.2. The following code executes EXCEPT it does not display the matching contents of the ‘items’ table. Any ideas?:

[bbcode]

<?php // This page will list all of the // from the items table. Each item will have // a link to add it to the cart include("db.php"); // Get a connection to the database $cxn = @mysqli_connect($dbServer, $dbUser, $dbPass, $dbName); if ($cxn->connect_error) { die("Connection failed: " . $cxn->connect_error); } echo "Connected successfully"; $result = mysqli_query($cxn, "select * from items where code = 'ply' order by itemId asc"); ?>
	<html>
	<head>
	<title> Murphy Plywood Samples </title>
	</head>
	<body bgcolor="#ffffff">
	<h2>Murphy Plywood Samples</h2>
	All raw plywood. See Prefinished Samples for UV, color and overlay.<br>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td width="15%" height="25" bgcolor="#0E6B02">
				<font face="verdana" size="1" color="white">
					&nbsp;&nbsp;<b>Product</b>
				</font>
			</td>
			<td width="10%" height="25" bgcolor="#0E6B02">
				<font face="verdana" size="1" color="white">
					<b>Add to Cart</b>
				</font>
			</td>
			<td width="10%" height="25" bgcolor="#0E6B02">
				<font face="verdana" size="1" color="white">
					<b>Price</b>
				</font>
			</td>
			<td width="50%" height="25" bgcolor="#0E6B02">
				<font face="verdana" size="1" color="white">
					<b>Description</b>
				</font>
			</td>
			
		</tr>
		<?php
		while($row = mysqli_fetch_array($result))
		{
		?>
			<tr>
				<td width="15%" height="25">
					<font face="verdana" size="1" color="black">
						<?php echo $row["itemName"]; ?>
					</font>
				</td>
				<td width="10%" height="25">
					<font face="verdana" size="1" color="black">
						<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
					</font>
				</td>
				<td width="10%" height="25">
					<font face="verdana" size="1" color="black">
						$<?php echo $row["itemPrice"]; ?>
					</font>
				</td>
				<td width="50%" height="25">
					<font face="verdana" size="1" color="black">
						<?php echo $row["itemDesc"]; ?>
					</font>
				</td>
			</tr>
			<tr>
				<td width="100%" colspan="4">
					<hr size="1" color="#006600" NOSHADE>
				</td>
			</tr>
		<?php
		}
	?>
		<tr>
			<td width="100%" colspan="4">
				<font face="verdana" size="2" color="black">
					<a href="cart.php">Go To Cart &gt;&gt;</a>
				</font>
			</td>
		</tr>
	</table>
</body>
[/bbcode]

Repost with BBCode tags:

<?php

	// This page will list all of the 
	// from the items table. Each item will have
	// a link to add it to the cart

	include("db.php");
	
	// Get a connection to the database
	$cxn = @mysqli_connect($dbServer, $dbUser, $dbPass, $dbName);
	
	if ($cxn->connect_error) {
   die("Connection failed: " . $cxn->connect_error);
}
  echo "Connected successfully";
	
	
	$result = mysqli_query($cxn, "select * from items where code = 'ply' order by itemId asc");
	?>
		<html>
		<head>
		<title> Murphy Plywood Samples </title>
		</head>
		<body bgcolor="#ffffff">
		<h2>Murphy Plywood Samples</h2>
		All raw plywood. See Prefinished Samples for UV, color and overlay.<br>
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td width="15%" height="25" bgcolor="#0E6B02">
					<font face="verdana" size="1" color="white">
						&nbsp;&nbsp;<b>Product</b>
					</font>
				</td>
				<td width="10%" height="25" bgcolor="#0E6B02">
					<font face="verdana" size="1" color="white">
						<b>Add to Cart</b>
					</font>
				</td>
				<td width="10%" height="25" bgcolor="#0E6B02">
					<font face="verdana" size="1" color="white">
						<b>Price</b>
					</font>
				</td>
				<td width="50%" height="25" bgcolor="#0E6B02">
					<font face="verdana" size="1" color="white">
						<b>Description</b>
					</font>
				</td>
				
			</tr>
			<?php
			while($row = mysqli_fetch_array($result))
			{
			?>
				<tr>
					<td width="15%" height="25">
						<font face="verdana" size="1" color="black">
							<?php echo $row["itemName"]; ?>
						</font>
					</td>
					<td width="10%" height="25">
						<font face="verdana" size="1" color="black">
							<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
						</font>
					</td>
					<td width="10%" height="25">
						<font face="verdana" size="1" color="black">
							$<?php echo $row["itemPrice"]; ?>
						</font>
					</td>
					<td width="50%" height="25">
						<font face="verdana" size="1" color="black">
							<?php echo $row["itemDesc"]; ?>
						</font>
					</td>
				</tr>
				<tr>
					<td width="100%" colspan="4">
						<hr size="1" color="#006600" NOSHADE>
					</td>
				</tr>
			<?php
			}
		?>
			<tr>
				<td width="100%" colspan="4">
					<font face="verdana" size="2" color="black">
						<a href="cart.php">Go To Cart &gt;&gt;</a>
					</font>
				</td>
			</tr>
		</table>
	</body>
</html>

Sorry. Forgot to mention the DB connection works!

The bbcode code tags, to put around your posted code, are - [code]...[/code]

If the expected data is not being displayed, what IS being displayed?

Next, don’t use @ error suppressors, ever. Don’t unconditionally output raw database errors onto a web page.

I figured it out. Thanks to those all giving it some thought.

Sponsor our Newsletter | Privacy Policy | Terms of Service