Jump to content
Larry Ullman's Book Forums

All Activity

This stream auto-updates     

  1. Yesterday
  2. I am not sure what I did but the previous issue is corrected, now I am getting the same error message at Tri, so I will consider this a completed task.
  3. Yep! Per http://php.net/manual/en/fileinfo.installation.php (I assume you're using Windows.)
  4. Larry, I am also working on script 8.10 and received the following error when I tried to send the email: Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\CreatingWebAppsCh8\register.phpon line 44. this is my line 44: mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@example.com'); I am running win10 on a 64bit system, xampp v3.2.2 and when I looked at the phpinfo.php file it was set for SERVER_PORT 80 but this is what the php.ini file has: [mail function] ; For Win32 only. ; http://php.net/smtp SMTP=localhost ; http://php.net/smtp-port smtp_port=25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = me@example.com I added the ini_set ini_set("smtp_port", 25); mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@example.com'); and received the same error message. I have looked at several different sources, including the php site and am still at a loss.
  5. Last week
  6. Hello, I am working through Chapter 13 – Validating Files by Type. I get an error when I try to submit an RTF file (or any file type for that matter) through script 13.3 – upload_rtf.php Fatal error: Uncaught Error: Call to undefined function finfo_open() in C:\Apache24\htdocs\PHP_and_MySQL\Chapter13\upload_rtf.php:18 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\PHP_and_MySQL\Chapter13\upload_rtf.php on line 18 Line 18 is where the resource is created to check the file type $fileinfo = finfo_open[FILEINFO_MIME_TYPE]; Running PHP 7.2.1 Is there a setting in php.ini that needs to changed, or can you point me in the right direction? Thanks, jrakow
  7. Hi everyone, I'm currently working on an assignment for my class that involves me creating a calculator and displaying certain form values with if then else statements. I attached a file to the assignment I'm working on below. So far my problem with this assignment is in ("Step 3, e") this step in the assignment requires me to create an if then else statement for hoursWorked between 0 and 80 and hourlyRate between 0 and 100. The next part of this assignment tells me if the conditions aren't met I must provide an error message, here is where I encountered problems in this assignment. When working on this assignment I got my error message to display but not in the right place, the error message is supposed to appear only during invalid data tests instead, the error message appears every time I click the submit button which I don't want it to do. I think the problem has to do with how I'm writing my if statement and I would appreciate it if anyone could look over my code and give me advice on how to display the error message properly, my code is listed down below. function calculate() { 'use strict'; var hoursWorked = document.getElementById('hoursWorked').value; if (hoursWorked.value <= 80 && hourlyRate.value <= 100) { } else { // Show an error: alert('Please enter valid hours and a valid payrate!'); } var regularHours = document.getElementById('regularHours').value; var overtimeHours = document.getElementById('overtimeHours').value; var hourlyRate = document.getElementById('hourlyRate').value; var ficaTax = document.getElementById('ficaTax').value; var stateTax = document.getElementById('stateTax').value; var federalTax = document.getElementById('federalTax').value; var regularPay = document.getElementById ('regularPay').value = parseFloat(regularHours*hourlyRate).toFixed(2); var overtimePay = document.getElementById ('overtimePay').value = parseFloat(overtimeHours*(hourlyRate*1.5)).toFixed(2); var grossPay = document.getElementById ('grossPay').value = parseFloat(+regularPay+ +overtimePay).toFixed(2); var totalTaxes = document.getElementById ('totalTaxes').value = parseFloat(+ficaTax+ +stateTax+ +federalTax)* grossPay /100 .toFixed(2); var netPay = document.getElementById ('netPay').value = parseFloat(grossPay-totalTaxes).toFixed(2); var employeeName; var firstName = document.getElementById('firstName').value; var lastName = document.getElementById('lastName').value; employeeName = firstName + ' ' + lastName; document.getElementById('employeeName').value = employeeName; return false; } // End of function. function init() { 'use strict'; document.getElementById('form1').onsubmit = calculate; } // End of init() function. window.onload = init; Paycheck2(1).pdf
  8. I found the files but am not familiar with GitHub. I created my profile but don't know how to download the files.
  9. Cool! This is why I always recommend to start by confirming the session ID to ensure it's not changing. That's the #1 cause of session problems in my experience. Glad it's working!
  10. Yes, I did not know that the 'with www' and 'without www' environments are separate. What initially threw me was that the session cookie was there in the browser in both situations. I have added some code in the site's .htaccess to remove the www if one is there. Thanks as always for your insights. Cheers from Oz.
  11. Ah, that totally makes sense! Because the subdomain was changing (from www. example.com to example.com), the session cookie wasn't available. This means a new session would be started each time and you'd lose access to the previously stored data.
  12. Hi Larry, I eventually found the root cause. If the initial URL uses the www prefix, the MVC redirect (via index.php) redirects without the www and the issue shows. If the initial URL does not use the www prefix, then all works OK. I think will use .htaccess to remove any wwws if they are there in the initial URL. Looking forward to your insights. Cheers from Oz, Necuima
  13. Sorry you didn't resolve the mysterious cause but I'm glad you figured it out and thanks for letting us know!
  14. Earlier
  15. In the end I followed some advice you have given, no doubt many times. I set up a new (temporary) test website using the same hosting folks as the production site. I pared the code right back and implemented it step by step and the problem has 'gone away'! I wish I knew though what the root cause of the problem was, but I've not finished my step-by-step process yet so as I add more and more modules the problem may recur. But at least then I'll know which module was causing the problem. Thanks as always for your advice. Necuima P.S., I am using your model-view-controller architecture as per your 'advanced' book.
  16. P.S., the same code runs perfectly in my XAMPP/Localhost test/development environment. As per "The King of Siam" - 'Tis a mystery.
  17. Re your other suggestion, I can see that the session cookie is getting set on the first try and is still there on the second try and gets deleted properly when I log out. And a new session gets set OK when I then log in again after logging out. A new session cookie is getting set OK without the problem as in this case I have not re-started the browser.
  18. Hi Larry, because I keep getting no session data when I test for its presence (the first time) I thought that I could use $GLOBALS instead. I am setting the values in $_SESSION, checking that they are set immediately afterwards, but in the second script my !isset test on the $_SESSION data says that the data are not set the first time I try to log in. But, without closing the browser down, the second time I try to log in I always get in - i.e., the second time the !isset test indicates that the $_SESSION data are indeed set and I can use them OK. I don't understand this at all! Again, your thoughts will be welcomed.
  19. Okay, so, first, $_SESSION and $GLOBALS aren't passed from script to script. They always exist and are read from the environment. But I'm not sure why you're using $GLOBALS at all. I don't think I've ever used that. Why aren't you setting values in the $_SESSION array like normal?
  20. In a situation like this, I'd start by verifying the session ID, which will tell you whether a new session is being started or not.
  21. Hi Larry, I am having the strangest issue with $_SESSION, which I have used many times before following the guidance in your books, and have never had a problem like this. For several days now I have been trying to debug an issue in a login script in a website. In a nutshell, a $_SESSION gets set in one module but even though I check that the $_SESSION (session_start())starts OK in another module in the same domain, and the $_SESSION (PHPSESSID) cookie is in the browser OK, the $_SESSION data are not there via if (!isset($_SESSION['MGCC_member_data'])) check. BUT if I log in again, without closing the browser down, then everything works fine! As far as I can tell, I have not sent anything to the browser before the $_SESSION data are checked. I have raised this with the hosting folks but would appreciate any insights that you may have. Thanks as always, Necuima
  22. Sorry, It is there but like this: [GLOBALS] => Array *RECURSION* I don't understand how to get the actual variables values here? Thanks as always, Neciuma
  23. Thanks for getting back to me. I think it is something to do with timing - maybe some JS code that runs at the bottom of the module interfering with the setting of the $_SESSION variables. But before I send you a whole bunch of code, can you please help me to understand why $GLOBALS array variables are not getting passed from script to script even though the PHP manual seems to indicate that $GLOBLS are super-globals? In the second script, still within the same domain, I do a dump of the variables but the ones I have set are not in there. $_SERVER; print_r($GLOBALS); The ones following are not there. Here's the setting code: $GLOBALS['MEMBER_KEY'] = $member_key; $GLOBALS['MEMBER_NUMBER'] = $member_number; $GLOBALS['MEMBER_FN'] = $member_first_name; $GLOBALS['MEMBER_LN'] = $member_last_name; Again, any advice will be most appreciated. Thanks, Necuima
  24. Hmmm...could you explain in more detail what you're seeing (i.e., what's not happening that should or what is happening that shouldn't)? The most details the better!
  25. Hi Larry, I have encountered a really weird problem (well weird to me) re the server not being able to write a session cookie reliably but it always gets set first go in localhost. I had to include a do-while loop in the production version until the session data were available but I don't know how many times the loop gets executed before the session cookie gets set. Can you offer any guidance on how to debug this? Am using IE11 and Firefox 62.0 Thanks as always, Necuima
  26. Where on your file system is your mysql_connect.php script? Also, please please please stop using all caps.
  27. Kudos for figuring it out and thanks for sharing the solution!
  1. Load more activity
×