php- blank page

0

[update1

ThisisthefollowingpagethatyoucanseeintheimageswasworkingbeautywithoutanyproblemandnowIhavebeenuploadingitandsimplythePHPcodedoesnotappear.I'vebeenreadingandsometimestheysaytheycanbemistakes.inaPHPcodecheckerIputmycodethereanditdidnotreturnanyproblem.Idonotunderstandwhathappened?sorrybutI'mnewtothis!

Ileavethecodethatisintheimage:

<?phpinclude('config.php');$sql="SELECT * FROM books WHERE category='computing'";
$r=mysqli_query($conn, $sql);
?>
<html>
    <head>
    </head>
    <body>
<table cellpadding="2" cellspacing="2" border="0">
<tr>
    <th>ISBN</th>
    <th> Title </th>
    <th> Author's name</th>
    <th> edition</th>
    <th> year</th>
    <th> category</th>
    <th> publisher</th>
    <th> quantity-in-stock</th>
    <th> price</th>
</tr>

<?php while($books =mysqli_fetch_object($r)){?>
    <tr>
    <td> <?php echo $books->ISBN;   ?></td>
    <td> <?php echo $books->Title;  ?></td>
    <td> <?php echo $books->Authorsname; ?></td>
    <td> <?php echo $books->edition;?></td>
    <td> <?php echo $books->year;   ?></td>
    <td> <?php echo $books->category;   ?></td>
    <td> <?php echo $books->publisher;  ?></td>
    <td> <?php echo $books->quantityinstock; ?></td>
    <td> <?php echo $books->price; ?></td>
    <?= echo '<img src="data:image/jpeg;base64,'.base64_decode( $books->Image ).'"/>'; ?>
    <td> <a href="shoppingcart.php?ISBN=<?php echo $books->ISBN; ?>">Order Now</a></td>
    </tr>
    <?php } ?>
</table>
    </body>
</html>

Thank you in advance

    
asked by anonymous 20.04.2017 / 05:53

2 answers

0

I made some adjustments below:

  

I changed the order of the parameters in mysqli_query and I used while with : instead of {} and removed base64_decode

<?php
include('config.php');

$sql= "SELECT * FROM books WHERE category='computing'";
$r=mysqli_query($sql, $conn);
?>
<html>
    <head>
    </head>
    <body>
<table cellpadding="2" cellspacing="2" border="0">
<tr>
    <th>ISBN</th>
    <th> Title </th>
    <th> Author's name</th>
    <th> edition</th>
    <th> year</th>
    <th> category</th>
    <th> publisher</th>
    <th> quantity-in-stock</th>
    <th> price</th>
</tr>

<?php while($books =mysqli_fetch_object($r)):?>
    <tr>
    <td> <?php echo $books->ISBN;   ?></td>
    <td> <?php echo $books->Title;  ?></td>
    <td> <?php echo $books->Authorsname; ?></td>
    <td> <?php echo $books->edition;?></td>
    <td> <?php echo $books->year;   ?></td>
    <td> <?php echo $books->category;   ?></td>
    <td> <?php echo $books->publisher;  ?></td>
    <td> <?php echo $books->quantityinstock; ?></td>
    <td> <?php echo $books->price; ?></td>
    <?php echo '<img src="data:image/jpeg;base64,'. $books->Image .'"/>'; ?>
    <td> <a href="shoppingcart.php?ISBN=<?php echo $books->ISBN; ?>">Order Now</a></td>
    </tr>
    <?php endwhile; ?>
</table>
    </body>
</html>
    
20.04.2017 / 06:23
0

You are confusing functions mysql_ with properties of mysqli , see this line:

while($books = mysqli_fetch_object($r))

The mysqli_fetch_object function you used does not exist. This would be mysql_fetch_object and that is obsolete since PHP 5.5.0 and was removed in PHP 7.0.0

With mysqli , to return resultset as a objeto , you must use the fetch_object() ", as follows:

while($books = $rs->fetch_object())
    
20.04.2017 / 15:16