Card Info Not Found. Can't Figure Out Why?

Hey Y’all,

I am having an issue with tying to get card info from my phpMyAdmin database table. It is saying that there is an issue with the variables in my table. “Undefined variable”, even tho there is data in the table on phpMyAdmin. Any help would be grateful. Thanks!

[php]<?php

$page_title = “Card Details”;
require_once (‘includes/header.php’);
require_once (‘includes/database.php’);

//if book id cannot retrieved, terminate the script.
if (!filter_has_var(INPUT_GET, “id”)) {
$conn->close();
require_once (‘includes/footer.php’);
die(“Your request cannot be processed since there was a problem retrieving the card information.”);
}

//retrieve book id from a query string variable.
$id = filter_input(INPUT_GET, “id”, FILTER_SANITIZE_NUMBER_INT);

//MySQL SELECT statement
$sql = “SELECT * FROM marketplace WHERE id=$id”;

//execute the query
$query = @$conn->query($sql);

//Handle errors
if (!$query) {
$errno = $conn->errno;
$error = $conn->error;
$conn->close();
require ‘includes/footer.php’;
die(“Selection failed: ($errno) $error.”);
}

?>

Book Details

Name:

Pokedex Number:

Type:

Generation:

Price:

Description:

Illustrator Name:

<?php echo $row['name'] ?>

<?php echo $row['pokedex'] ?>

<?php echo $row['type'] ?>

<?php echo $row['generation'] ?>

<?php echo $row['price'] ?>

<?php echo $row['description'] ?>

<?php echo $row['illustrator_name'] ?>

<?php require_once ('includes/footer.php'); [/php]

I found out it has to do with my inventory.php with the select statement. With the current code shown, when I try to add a card, with the my addbook.php site (not shown), it adds the card, but does not show it on the inventory page, unless I get rid of the where statement and make it only from the marketplace table, but if I do that, none of the card info on the previous post isn’t shown, so I am not sure exactly how to make it work!

Thanks!

[php]<?php

$page_title = “Pokémon Vault Inventory”;

require (‘includes/header.php’);
require_once(‘includes/database.php’);

//SELECT statement
$sql = “SELECT *”
. "FROM marketplace, types "
. “WHERE marketplace.type_id = types.type_id”;

//execute the query
$query = @$conn->query($sql);

//Handle errors
if (!$query) {
$errno = $conn->errno;
$error = $conn->error;
$conn->close();
require ‘includes/footer.php’;
die(“Selection failed: ($errno) $error.”);
}
?>

<header class="intro-header" style="background-image: url('img/inventory.jpg')">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <div class="site-heading">
                    <h3></h3>
                    <!-- <hr class="small"> -->
                    <span class="subheading"></span>
                </div>
            </div>
        </div>
    </div>
</header>
<?php while ($row = $query->fetch_assoc()) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } ?>
Image Name Generation Price Description
", $row['name'], "", $row['generation'], "", $row['price'], "", $row['description'], "
<?php require ('includes/footer.php'); [/php]

Turn on error reporting and stop hiding errors with @.

How do I turn on error reporting? Is that what is making the issue?

You don’t need to concatentate the line.

This is what is being sent to the database:

[php]$sql = “SELECT *”
. "FROM marketplace, types "
. “WHERE marketplace.type_id = types.type_id”;[/php]
It translates to:

$sql = "SELECT *FROM marketplace, types WHERE marketplace.type_id = types.type_id";

Proper joins are ALWAYS preferred.

I’ve done that multiple times and it still doesn’t work. I just went on another direction and made a buy/sell function the add/update/delete statement for my website. I have having trouble with price, as when I add or update a price, from the website itself, it is moving the decimal over. When I type in 5.75, it saves it as 575.00. I am not sure how to correct it, but I do appreciate your help on this!

Sponsor our Newsletter | Privacy Policy | Terms of Service