Click here to Skip to main content
15,668,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been working on this for a while and I just can't figure out how to make it work! I keep getting the same error. For reference, I am trying to generate a dynamic link so when I click on a button from my list page it generates content on a second page.

If you want to see the list page code, let me know. Here is the dynamic page:

What I have tried:

if(isset($_GET['id'])) {
require_once  'login1.php';

$dbc = null;

$conn = new mysqli($hn, $un, $pw, $db); //these three lines connect to the db with the login file
if($conn->connect_error) die($conn->connect_error); //all the lines above here will be in all your codes

	$sql = "SELECT * FROM freshwater WHERE id='$id' ";
	$result = mysqli_query($dbc, $sql) or die("Bad Query: $sql");
	$row = mysqli_fetch_array($result);
<title>Fish R Us - Saltwater Fish</title>

<div class="toptext"><center>
<img src="banner.png" height="300"></img></center>
<h2><?php echo $row['name'] ?></h2>
width="150" height="150"
<img src="<?php echo $row['picture'] ?>" width="150" height="150"></img>
    <td><?php echo $row['name'] ?></td>
    <td><?php echo $row['type'] ?></td>
    <td><?php echo $row['qty'] ?></td>
	<td><?php echo $row['price'] ?></td>
<table class="fish-text">
<th><?php echo $row['description'] ?></th>
<button padding: 10px 24px;><a href="products.php">Return to Products List</a></button></body>
<button padding: 10px 24px;><a href="menu.php">Return to Menu</a></button>
Updated 18-Apr-19 7:25am

1 solution

$dbc = null;
$result = mysqli_query($dbc, $sql) or die("Bad Query: $sql");

You forgot to initialize the $dbc variable. Did you perhaps mean to pass $conn instead?
Share this answer
Member 14315682 18-Apr-19 14:35pm    
Thank you so much! I switched to Conn and it's not throwing that error anymore! I so appreciate the help. Now my issue is that it's not pulling data from the database but I'm not getting any errors. Hmm...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900