Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Problem with book code

Mathman54

New Coder
HI,
Yesterday I installed and tested Mysql, php 8 and Apache 2.4. Today I was using this book Learning PHP 7. I can't seem to get the code to display in a web page. Here is a copy of the code
Code:
<?php
$looking = isset($_GET)['title']) || isset($_GET['author']);
?>
<!doctype html>
<html lang = "en">
<head>
    <meta charset ="UTF-8">
    <title>Bookstore</title>
    </head>
    <body>
    <p><you looking'? <?php echo (int) $looking; ?> </p>
    <p>The book you are looking for is </p>
    <ul>       
            <li><b>Title</b>: <?php echo $_get['title']; ?></li>
            <li><b>Author</b> <?php echo $_get[author']; ?></li>
        </ul>
        </body>
        </html>
Why is this not working?
 
Your problem is with this line:
Code:
$looking = isset($_GET)['title']) || isset($_GET['author']);
Because it makes no sense.
isset return 'true' or 'false' - why would you want $looking to be either if your using it in this line
Code:
<p><you looking'? <?php echo (int) $looking; ?> </p>
You looking? true What does that ? after $looking do?
First line has two closing parenthesis but no opening one. And using an OR (||) yeilds what if one is true and the other false?

You did save this code with the .php extension and not .html
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom