Jump to content
Larry Ullman's Book Forums

ezrapound

Members
  • Posts

    11
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ezrapound

  1. Datetime script returns: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Anguilla' for 'AST/-4.0/no DST' instead' in /var/www/html/testing/datetime.php:16 Stack trace: #0 /var/www/html/testing/datetime.php(16): DateTime->__construct() #1 {main} thrown in /var/www/html/testing/datetime.php on line 16 timezone is set to "Canada/Atlantic" in php.ini
  2. OOPS! my function was in the wrong directory. The message means EXACTLY what it says.
  3. create_window is not defined javascript:create_window('laptop.jpeg',225,%20225)
  4. When I hover on a filename, I see the javascript reference in the bottom bar of the firefox screen, but when I click on it nothing happens. php looks like this: <!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd"> <html xmlns="http://w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Images</title> <script type="text/javascript" charset="utf-8" src="js/function.js"> </script> <link rel="stylesheet" href= "style.css" type = "text/css" media = "all" /> <meta http-equiv="content-type" content = "text/html; charset=utf-8" /> </head> <body> <p>Click on an image name to view it in a separate window.</p> <ul> <?php # script 11.4 - images.php Written Dec 22, 2013 $dir = '../../../uploads'; $files = scandir($dir); foreach ($files as $image) { if (substr($image, 0, 1) != '.') { // check for non-dotted (system) files $image_size = getimagesize ("$dir/$image"); $image_name = urlencode($image); echo "<li><a href=\"javascript:create_window('$image_name',$image_size[0], $image_size[1])\">$image </a></li>\n"; } // end of IF } ?> </ul> </body> </html> Generated code in images.php looks like this: <!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd"> <html xmlns="http://w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Images</title> <script type="text/javascript" charset="utf-8" src="js/function.js"> </script> <link rel="stylesheet" href= "style.css" type = "text/css" media = "all" /> <meta http-equiv="content-type" content = "text/html; charset=utf-8" /> </head> <body> <p>Click on an image name to view it in a separate window.</p> <ul> <li><a href="javascript:create_window('laptop.jpeg',225, 225)">laptop.jpeg </a></li> <li><a href="javascript:create_window('laptop2.jpeg',225, 225)">laptop2.jpeg </a></li> <li><a href="javascript:create_window('neuman.jpeg',222, 227)">neuman.jpeg </a></li> </ul> </body> </html>
  5. I started there, but no luck. Seems like it must ba a browser issue, though.
  6. I got the script working properly, but every time I run it, it puts initial values in email and pass1 boxes. Always the same values (I think. Obviously I cannot see the pass1 value.). If I access from another computer the boxes are clear. Where might it be picking up the information?
  7. ([[:alnum:]]){2,4} is to check for the .com, .co, etc. Using the book from which I'w working, the [[:alnum:]] construct seems to be a pre-defined class.
  8. I submitted items that should evaluate as true. They pass in the first two instances, but the third one fails.
  9. I am using php 5.3 with the php 3 and php 4 book. I've hade to substitute preg_match for eregi. It's working for the first two but not the third test, below. Any suggestions for what's wrong? if (!preg_match("#^[[:alpha:].'-]{4,}$#i", stripslashes(trim($_POST['name'])))) { $problem = TRUE; $message .='<p>Please enter a valid name.</p>'; } if (!preg_match("#^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$#i", stripslashes(trim($_POST['email'])))) { $problem = TRUE; $message .='<p>Please enter a valid email address.</p>'; } if (!preg_match("#^((http|https|ftp)://)? ([[:alnum:]-])+(\.) ([[:alnum:]]){2,4} ([[:alnum:]/+=%&_.~?-]*)$ #i", stripslashes(trim($_POST['url'])))) { $problem = TRUE; $message .='<p>Please enter a valid URL.</p>'; } I've tried with several values which should be valid URL names.
  10. Thanks for the help. The 41 characters is the answer. I should have clued in when I got truncation messages when loading the table.
  11. I plugged in a display of $result to see why update is failing (It drops through to "Your username and password do not match our records") and $result contains "Resource id #5". Is this a compatibility issue? I believe I'm using the first edition of your book, but I've downloaded the scripts posted at your site. I've done further debugging and it appears I'm failing on the match for password. I've used the register.php script to insert a user, but I can't get a password match when I try to retrieve the record. Here is the code: if ($u && $p && $np) { // If everything's OK. $query = "SELECT user_id FROM users WHERE (username='$u' AND password=PASSWORD('$p') )"; $result = @mysql_query ($query); $num = mysql_num_rows ($result); if ($num == 1) { $row = mysql_fetch_array($result, MYSQL_NUM); // Make the query. $query = "UPDATE users SET password=PASSWORD('$np') WHERE user_id=$row[0]"; $result = @mysql_query ($query); // Run the query. if (mysql_affected_rows() == 1) { // If it ran OK. // Send an email, if desired. echo '<p><b>Your password has been changed.</b></p>'; include ('templates/footer.inc'); // Include the HTML footer. exit(); // Quit the script. } else { // If it did not run OK. $message = '<p>Your password could not be changed due to a system error. We apologize for any inconvenience.</p><p>' . mysql_error() . '</p>'; } } else { $message = '<p>Your username and password do not match our records.</p>' . $result ; //show result for debugging } mysql_close(); // Close the database connection. } else { $message .= '<p>Please try again.</p>'; } } // End of the main Submit conditional.
×
×
  • Create New...