Author Topic: Card Info Not Found. Can't Figure Out Why?  (Read 234 times)

Gaomon

  • New Member
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  <?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.");
 }
 
 
?>
 
<header class="intro-header" style="background-image: url('img/carddetails.png')">
         <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>
 
 <h2>Book Details</h2>
 <table id="carddetails" class="carddetails">
     <tr>
         <td class="col1">
            <img width="225" height="300" src="<?php echo $row['image'?>" alt="" />
         </td>
         <td class="col2">
             <h4>Name:</h4>
             <h4>Pokedex Number:</h4>
             <h4>Type:</h4>
             <h4>Generation:</h4>
             <h4>Price:</h4>
             <h4>Description:</h4>
             <h4>Illustrator Name:</h4>
         </td>
         <td class="col3">
             <p><?php echo $row['name'?></p>
             <p><?php echo $row['pokedex'?></p>
             <p><?php echo $row['type'?></p>
             <p><?php echo $row['generation'?></p>
             <p><?php echo $row['price'?></p>
             <p><?php echo $row['description'?></p>
             <p><?php echo $row['illustrator_name'?></p>
         </td>
         </tr>
 </table>
 <script src="www/js/main.js"></script>
 <p id="delete-buttons">
     <input type="button" value="  Delete Card  " onclick="confirm_deletion(<?php echo $id ?>)" >
 </p>
 
 <?php
 
require_once ('includes/footer.php');
 


PHP Help Forum

Card Info Not Found. Can't Figure Out Why?
« on: April 19, 2017, 09:54:41 pm »


Gaomon

  • New Member
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  <?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.");
 }
 
?>
 

 
 <!-- Background image for Inventory page -->
     <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>
 
 <div class="container">
         <table id="cardlist" class="cardlist" margin="15px">
     <tr>
         <th class="col2">Image</th>
         <th class="col2">Name</th>
         <th class="col4">Generation</th>
         <th class="col4">Price</th>
         <th class="col4">Description</th>
     </tr>
     <?php
     
while ($row $query->fetch_assoc()) {
         echo 
"<tr>";
         echo 
"<td> <img height='84' width='63' src="$row['image'], "></td>";
         echo 
"<td><a href='carddetails.php?id="$row['id'], "'>"$row['name'], "</a></td>";
         echo 
"<td text-align='center'>"$row['generation'], "</td>";
         echo 
"<td>"$row['price'], "</td>";
         echo 
"<td>"$row['description'], "</td>";
         echo 
"</tr>";
     }
     
?>
 
</table>
     </div>
 
         
         
 <?php
 
 
require ('includes/footer.php');
 


PHP Help Forum

Re: Card Info Not Found. Can't Figure Out Why?
« Reply #1 on: April 19, 2017, 10:18:43 pm »


Kevin Rubio

  • Professional PHP Helper
  • Senior Member
  • *
  • Posts: 1844
  • Karma: 108
  • Programmer Available for hire
    • View Profile
    • Galaxy Internet
PDO Bumpstart Database

The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. http://xyproblem.info/

PHP Help Forum

Re: Card Info Not Found. Can't Figure Out Why?
« Reply #2 on: April 20, 2017, 12:04:48 pm »



PHP Help Forum

Re: Card Info Not Found. Can't Figure Out Why?
« Reply #3 on: April 20, 2017, 06:33:07 pm »


astonecipher

  • Software Engineer
  • Professional PHP Helper
  • Senior Member
  • *
  • Posts: 2437
  • Karma: 95
    • View Profile
You don't need to concatentate the line.


This is what is being sent to the database:

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


It translates to:

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

Proper joins are ALWAYS preferred.
Questions? Go here first.
http://www.phptherightway.com/

PHP Help Forum

Re: Card Info Not Found. Can't Figure Out Why?
« Reply #4 on: April 21, 2017, 09:32:19 am »



PHP Help Forum

Re: Card Info Not Found. Can't Figure Out Why?
« Reply #5 on: April 21, 2017, 02:24:58 pm »