Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL 24-Hour Trainer
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL 24-Hour Trainer
This is the forum to discuss the Wrox book PHP and MySQL 24-Hour Trainer by Andrea Tarr ; ISBN: 978-1-1180-6688-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 10th, 2012, 08:57 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6 php and mysql 24-hour trainer

I get the following warning on all my coding using 'strftime':

"Warning: Invalid CRT parameters detected in C:\Users\chuck\Desktop\Documents\php\xampp\htdocs\ php24\employee.php on line 56"

Warning: Invalid CRT parameters detected in C:\Users\chuck\Desktop\Documents\php\xampp\htdocs\ php24\employee.php on line 59

Warning: Invalid CRT parameters detected in C:\Users\chuck\Desktop\Documents\php\xampp\htdocs\ php24\employee.php on line 60

There are five (5) identical Warning msgs for each line.

I created the following code:
Code:
	 <?php
line 56		echo '<p>Original date/time: ' . strftime('%A, %B %e, %Y %I:%M%p %Z') . '</p>';
line 57		echo '<p>New date/time in different formats: </p>';
line 58		echo strftime('%c', $myTime) . '<br />';
line 59		echo strftime('%m/%e/%Y', $myTime) . '<br />';
line 60		echo strftime('%A, %B %e, %Y', $myTime) . '<br />';
line 61		echo strftime('%A %I:%M%p %Z', $myTime) . '<br />';
line 62		echo strftime('%I:%M %p', $myTime) . '<br />';
	?>
I get the Warning listed above on lines 56, 59 and 60. The other lines of coding is processed.

I downloaded the following code from wrox.com:
Code:
	 <?php
line 56		echo '<p>Original date/time: ' . strftime('%A, %B %e, %Y %I:%M%p %Z') . '</p>';
		echo '<p>New date/time in different formats: </p>';
		echo strftime('%c', $myTime) . '<br />';
line 59		echo strftime('%m/%e/%Y', $myTime) . '<br />';
line 60		echo strftime('%A, %B %e, %Y', $myTime) . '<br />';
		echo strftime('%A %I:%M%p %Z', $myTime) . '<br />';
		echo strftime('%I:%M %p', $myTime) . '<br />';
	?>
I have defined $myTime at the top of the coding. It is defined as:

Code:
$myTime = time()+ (60 * 60 * 24 * 7);
The coding is the same for my entries and what I down loaded from WROX. The same lines of coding had the WARNING error.

What is wrong?
Reply With Quote
  #2 (permalink)  
Old April 11th, 2012, 12:12 PM
Tarrconsulting's Avatar
Wrox Author
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is that the %e is not supported by Windows. I'm on a Mac and missed it. You can replace it with %#d instead.

%e shows the day without leading zeros 1-31
%d shows the day with leading zeros 01-31
%#d shows the day without the leading zeros 1-31

If you don't care if a leading zero shows, you could just replace the %e with %d
Reply With Quote
  #3 (permalink)  
Old April 12th, 2012, 06:33 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson 06x.php

Thanks for the quick reply on my question for lesson06w. Now I have another one:
I'm trying to use the $_GET function (lesson06x). My coding (which is exactly like the downloaded version of lesson06x gets the error:

User Name: Andy

Password 12345

You entered
Notice: Undefined index: username in C:\Users\chuck\Desktop\Documents\php\xampp\htdocs\ php24\employee-first.php on line 84
as the User Name and
Notice: Undefined index: password in C:\Users\chuck\Desktop\Documents\php\xampp\htdocs\ php24\employee-first.php on line 84
as the Password.

I copied the downloaded version of lesson06x from WROX and ran it:
Code:
	<form action="lesson06x.php" method="get">
<label for="username">User Name:</label><br />
<input type="text" id="username" name="username" /><br />
<label for="password">Password</label><br />
<input type="text" name="password" /><br />
<button type="submit">Submit</button>
</form>
<p>You entered <?php echo $_GET["username"] ?> as the User Name and <?php echo $_GET["password"] ?> as the Password.</p>
I get the same errors. Can you tell me what's wrong?
Reply With Quote
  #4 (permalink)  
Old April 12th, 2012, 08:19 PM
Tarrconsulting's Avatar
Wrox Author
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Notice error is happening because the first time you open the file the form hasn't been submitted so there are no GET's defined yet. To get rid of these errors when we need to check first that the GET's are defined. We can do that with the isset() function.

Replace the <p></p> line with this:

Code:
<?php if (isset($_GET["username"]) AND isset($_GET["password"])) : ?>
	<p>You entered <?php echo $_GET["username"] ?> as the User Name and <?php echo $_GET["password"] ?> as the Password.</p>
<?php else: ?>
	<p>Please enter your User Name and Password.</p>
<?php endif; ?>
This was just an example and you'll find as you go on we start adding in more robust features.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions about the Access 2010 24 Hour Trainer Book? Post them here! gjgriffith BOOK: Microsoft Access 2010 24-Hour Trainer 2 January 30th, 2012 04:14 PM
HTML 5 24-Hour Trainer nathan613 BOOK: HTML5 24-Hour Trainer 0 May 23rd, 2011 08:14 PM
HTML 5 24-Hour Trainer nathan613 BOOK: HTML5 24-Hour Trainer 0 May 22nd, 2011 08:02 PM
9th BME International 24-hour Programming Contest challenge24 C++ Programming 0 January 21st, 2009 05:47 PM
How to show 24 Hour Time? Edward King Oracle 1 July 31st, 2004 04:44 AM



All times are GMT -4. The time now is 06:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.