Jump to content



Photo

Chapter 3 On Page 64 Related Error Result


  • Please log in to reply
37 replies to this topic

#21 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 12 April 2017 - 7:33 PM

On page 128, Chapter 6:

 

I am lost.  Please rephrase it with plain English for me.  I rather to wait to hear from you before I put that program on my CodeRunner.


Edited by jeffreader, 12 April 2017 - 7:34 PM.

  • 0

#22 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 12 April 2017 - 7:40 PM

Could you elaborate on what you're lost on and what you'd like me to rephrase? 


  • 0

#23 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 12 April 2017 - 8:01 PM

Could you elaborate on what you're lost on and what you'd like me to rephrase? 

I can't fresh my mind.  The var1 to var3 have different and also empty().  It is same thing for isset(). 

 

Actually, I thought that there is only one var that something to clear out for one example but it has three examples (i.e. var1, var2, var3).

I am not sure why do I have to know about them.


  • 0

#24 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 19 April 2017 - 3:49 PM

So the examples are just trying to demonstrate what it means to be "set", "empty", and "numeric" and uses a couple of different values--represented by variables--to do so. 


  • 0

#25 lorne

lorne

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 11 June 2017 - 2:33 PM

Every time I hit "send my feedback" button I get this. 

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charest="utf-8">
<title>Feedback Form</title>
</head>
<body>
<?php // Script 3.3 handle_form.php

// This page receives the data from feedback.html.
// It will receive: title, name, email, response, comments, and submit in $_POST.

// Create shorthand versions of the variables:
$title = $_POST['title'];
$name = $_POST['name'];
$response = $_POST['response'];
$comments = $_POST['comments'];

// Print the received data:
print "<p>Thank you, $title $name, for your comments.</p>
<p>You stated that you found this example to be '$response' and added:<br>$comments</p>";

?>
</body>
</html>


Edited by lorne, 11 June 2017 - 2:38 PM.

  • 0

#26 lorne

lorne

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 11 June 2017 - 6:13 PM

The first error was caused by not loading feedback.html through a URL.

 

Now I get this error when I hit submit

Notice: Undefined index: title in /Applications/XAMPP/xamppfiles/htdocs/handle_form.php on line 14

Notice: Undefined index: name in /Applications/XAMPP/xamppfiles/htdocs/handle_form.php on line 15

Notice: Undefined index: response in /Applications/XAMPP/xamppfiles/htdocs/handle_form.php on line 16

Notice: Undefined index: comments in /Applications/XAMPP/xamppfiles/htdocs/handle_form.php on line 17

Thank you, , for your comments.

You stated that you found this example to be '' and added:


  • 0

#27 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 14 June 2017 - 2:48 PM

Just to confirm, you see that when you load feedback.html through a URL, fill out the form completely, and then submit the form?


  • 1

#28 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 25 July 2017 - 4:41 PM

On page 205, my website does not look the same design as yours.  What is the problem with mine?

 

third.jpg


  • 0

#29 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 25 July 2017 - 7:11 PM

My template file:

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-with,inital-scale=1.0">
        <mega name="HandheldfFriendly" content="True">
        <title>Raise High the Roof Beam!</title>
        <link rel="stylesheet" type="text/css" media="screen" href="css/concise.min.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="css/masthead.css" />
    </head>
    <body>
    
        <header container class="siteHeader">
            <div row>
                <h1 column=4 class="logo"><a href="index.php">Raise the Roof Beam!</a></h1>
                <nav column="8" class="nav">
                    <ul>
                        <li><a href="books.php">Books</a></li>
                        <li><a href="#">Stories</a></li>
                        <li><a href="#">Quotes</a></li>
                        <li><a href="login.php">Login</a></li>
                        <li><a href="register.php">Register</a></li>
                    </ul>    
                </nav>
            </div>
        </header>
        
        <main container class="siteContent">
        <!-- BEGIN CHANGEABLE CONTENT. -->
        <h2>Welcome to a J.D. Salinger Fan Club</h2>
        <p>lorem ipsum dolor sit amet, consecetur adipisicing elit, sed, do eisumod tempor incidendunt ut labore et dolore amgna aliqua.  Ut enim ad minim venia, quis motrud exercitation ullamco laboris nisi ut aliquip ex ea comodo consequat.  Duis aute irure dolor inreprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.  Excepteur sin occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        <!-- END CHANGEABLE CONTENT. -->
        </main>
        
        <foot container class="siteFooter">
            <p>Design uses <a href="http://concisecss.com/">ConciseCSS Framework</a></p>
            </footer>
            
    </body>
</html>


  • 0

#30 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 27 July 2017 - 11:29 AM

This would be a CSS issue. Do you have the two CSS files in a "css" folder in the same directory as the rest of the site? Also, if you look in your browser's developer tools, you should see an error message (in the console or elsewhere) about the page not being able to load the CSS files.


  • 0

#31 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 1 August 2017 - 7:41 PM

Hi Larry,

 

I created the folders like this.  Does it look right to you?

 

index/index.php

index/css/template.html

index/templates/footer.html

index/templates/headers.html

 

folders.jpg


  • 0

#32 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 9 August 2017 - 5:37 PM

Where did you get the concise.min.css and masthead.css?

 

Look on page 205 and read the number 12.


  • 0

#33 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 14 August 2017 - 3:23 PM

Yeah, you need to put the CSS files in the css directory. They're available in the downloadable code: https://github.com/L...e/master/08/css


  • 0

#34 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 25 August 2017 - 10:28 PM

On page 227, it says, "Save the file as register.php, place it in the proper directory on your PHP-enabled server, and test it in your browser (D) and (E).

 

my iMac runs on XAMPP 7.0.13-1.  Is that part of the PHP-enabled server?

 

My Firefox browser stated, "
Parse error: syntax error, unexpected 'define' (T_STRING) in /Applications/XAMPP/xamppfiles/htdocs/practice/forlogin/register.php on line 5."

 

Am I supposed to put my files on a hosting website in order to activate the register.php?

 

Line number 5 on my register.php  is: "define('TITLE', 'Register');

 

Now, I'm lost.


  • 0

#35 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 29 August 2017 - 3:54 PM

http://localhost/pra...in/register.php

 

My browser says with an error statement:

 

"Parse error: syntax error, unexpected 'define' (T_STRING) in /Applications/XAMPP/xamppfiles/htdocs/practice/forlogin/register.php on line 5."

 

 

My line for number 5:  define('TITLE', 'Register');

 

Parse error means there is a problem with omission of semicolon or an imbalance of quotation marks, braces, or parentheses. (On page 65.) 

 

On the error statement, What is T_STRING?

 

---------------------------------

Here is the source:

 

<?php// Script 8.9 - register.php
/* This page lets people register for the site (in theory). */

// Set the page title and include the header file:
define('TITLE', 'Register');
include('templates/header.html');

// Print some introductory text:
print '<h2>Registeration Form</h2>
    <p>Register so that you can take advantage of certain features like this, that, and the other thing.</p>';
    
// Check if the form has been submitted:
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            
            $problem = false; // No problems so far.
            
            // Check for each value...
            if (empty($_POST['first_name'])) {
                $problem = true;
                print '<p class="text--error">Please enter your first name!</p>';
                
            }
            
            if (empty($_POST['last_name'])) {
                $problem = true;
                print '<p class="text--error">Please enter your last name!</p>';
                
            }
            
            if (empty($_POST['email'])) {
                $problem = true;
                print '<p class="text--error">Please enter your email address!</p>';
                
            }
            
            if (empty($_POST['password1'])) {
                $problem = true;
                print '<p class="text--error">Please enter your a password!</p>';
                
            }
            
            if ($_POST['password1'] != $_POST['password2']) {
                $problem = true;
                print '<p class="text--error">Your password did not match your confirmed password!</p>';
                
            }
            
            if (!$problem) { // If there were not any problems...
            
                // Print a message:
                    print '<p class="text--success">You are now registered!<br>Okay, you are not really registered but...</p>';
                    
                // Clear the posted values:
                    $_POST = [];
                        
            } else { // Forgot a field.
            
                print '<p class="text--error">Please try again!</p>';
                
        }
        
    } // End of handle form IF.
    
    // Create the form:
?>
<form action="register.php" method="post" class="form--inline">

    <p><label for="first_name">First Name:</label><input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])) { print htmlspecialchars($_POST['first_name']); } ?>"></p>
    
    <p><label for="last_name">Last Name:</label><input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])) { print htmlspecialchars($_POST['last_name']); } ?>"></p>
    
    <p><label for='password1'>Password:</label><input type="password" name="password1" size="20" value="<?php if (isset($_POST['password1'])) { print htmlspecialchars($_POST['password1']); } ?>"></p>
    
    <p><label for='password2'>Confirm Password:</label><input type="password" name="password2" size="20" value="<?php if (isset($_POST['password2'])) { print htmlspecialchars($_POST['password2']); } ?>"></p>
    
    <p><input type="submit" name="submit" value="Register!" class="button--pill"></p>
    
</form>

<?php include('templates/footer.html');
// Need the footer.  ?>


  • 0

#36 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 1 September 2017 - 11:42 AM

I finally found the problem with a T_STRING.  It's really really small error into a big error.  Like this:

 

Source:

 

<?php// Script 8.9 - register.php
/* This page lets people register for the site (in theory). */

 

 

It should be like this:  <?php // Script 8.9 - register.php       (  Space between <?php       //    )   OMG!

 

 

Now, I have a question that might be easy for you to answer my problem.  (Note: I forgot to add the email in code for the form so I added it.)

 

On the screen form, there is a missing text box for Email Address:.  Here is my source.   Thanks.

 

register.jpg

 

 

printout.jpg


  • 0

#37 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4785 posts
  • LocationState College, PA (USA)

Posted 1 September 2017 - 2:22 PM

Kudos for figuring it out and thanks for sharing your solution! As for this new problem, you're missing the "n" in the word "input". 


  • 0

#38 jeffreader

jeffreader

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSouth Windsor, CT

Posted 4 September 2017 - 2:38 PM

Perfect!   Many thanks!

 

It's too bad that my CodeRunner does not show me the different color for the error statement if you know what I mean.  I do not have a Sublime Text if it would show me the color error.  Beside, I am not familiar with other software.  i.e.  Atom, Coda, etc.  I have to protect my eyes from looking at the monitor for too long.


  • 0