Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

NickReferee's Achievements


Rookie (2/14)

  • One Month Later Rare
  • First Post Rare
  • Conversation Starter Rare
  • Week One Done Rare

Recent Badges



  1. Hi everyone, I'm using msmtp and gmail to send email in my php web app, on Ubuntu in localhost developing. It is described here: https://stackoverflow.com/questions/33969783/phpubuntu-send-email-using-gmail-form-localhost/45125490#45125490 It works both when I send the email to me and when I receive an email. However in the latter case, i.e. when I send an email to me, I can't see the address email of the sender but I see me ,I believe because is in effect my mail server that send to me. How could I see the email address of the sender when I receive the email? Is there some advice or easy solution to the problem encountered? Best greetings
  2. Chapter 7 page 240. The salt nacl is saved like VARBINARY(64) but its dimension is always 64 byte thereby could be better BINARY(64). Furthermore nacl=UNHEX(SHA2(RAND(),512) uses RAND() that has low entropy, you could use RANDOM_BYTES(len) with len>16 namely nacl=UNHEX(SHA2(RANDOM_BYTES(20),512) Furthermore I didn't undestand one thing: RAND() return a FLOAT and SHA2() function need as first parameter a String thus how does it work? Is there in MySQL an automatic conversion from float to String? Best regards Nick
  3. Good morning Mr. Larry. Thanks for the reply. I delved into the question and I have found a solution in MYSQL: START TRANSACTION; UPDATE accounts SET balance = (balance-100) WHERE account_id = 2 AND balance>100; UPDATE accounts SET balance = (balance+100) WHERE account_id =1 AND ROW_COUNT(); -- check does a row was altered in previous statement -- if not then this statement will not alter any row too COMMIT; I discovered the ROW_COUNT() function that return how much rows has affected from previous INSERT,UPDATE,DELETE About second question I found out that InnoDB tables have a lock by default(https://dev.mysql.com/doc/refman/8.0/en/innodb-locks-set.html) thereby no problem with multiple user modify of a record.
  4. Hi, I'm learning transactions (chapter 7, from 236 to 238 page). I have some doubts. The example on the book (tha bank account) is meant for be manually checked, but i think in a real application this check should be automatic. For example (example like that in the book): START TRANSACTION; UPDATE accounts SET balance = (balance-100) WHERE account_id = 2 AND balance>100; --If the above query is succesfully then: UPDATE accounts SET balance = (balance+100) WHERE account_id =1; --How can I exec the commit only if everything is ok? COMMIT; Respect to the book, in the first query I added the check . The first query is executed only if the balance>100. However the second query (namely the second update) should be executed only if the prevoious query has decreased the balance. How could I automatically check this? Furthermore the COMMIT; has to be executed only if the previous 2 queries have done their job. How could this be implemented? Another question about transaction is relative to multiple concurrent access to a database i.e. the scenario is that I have more users that access in writing in the same time the same record of a table. For example an UPDATE that modify the amount of available t-shirts (2 users in the same time decrease this amount). Sql database guarantees atomicity of an UPDATE query (and other queries)? (Because if the UPDATE queries can be "scheduled" you could have a wrong result) Thanks in advance. And compliments on the book. Best regards.
  5. Hi Larry, I have resolved on my own (really with the aid of stackoverflow). It's a cache problem. I have substituted my css link tag with him: <link href="css/sticky-footer-navbar.css?v=<?php echo time(); ?>" rel="stylesheet"> to force to use the fresh version (surely I could to empty the cache too). Or I could include the css like that: <style> <?php include "css/sticky-footer-navbar.css" ?> </style> However those above are not the best solutions because force ever the browser to make an http request to download the css file (thus the user will never use the cache copy though if my css has not been changed). The best way is to use: <link href="css/sticky-footer-navbar.css?v=1" rel="stylesheet"> And when I change the css file I have to remember to do: <link href="css/sticky-footer-navbar.css?v=2>" rel="stylesheet"> to force the download instead of the cache version. I haven't closed the post because could be useful to someone else. This link https://stackoverflow.com/questions/50662906/my-css-file-not-working-in-my-php-file helped me Regards Nicola
  6. I was trying to solve the second exercise (Pursue) of the third chapter, namely to add a textarea and a checkbox. I haven't created a new form, I have reused your form, I have simply added the textarea and made it a sticky form again (My textarea is deliberately optional). But I encountered a problem that was a very "pain in the ass" (I'm not a native english, it is a dirty word? sorry if is this the case 😇). I tried to style my textarea, with a background-color:red and a resize:vertical properties in css/sticky-footer-navbar.css but they don't work. If I give them as inline style instead they work. I'm not able to figure out what is the problem, may be I'm missing something. There is the attached code, it's very very similar to your code. Little change described above. Please, can you help me to understand where I'm wrong? Thanks in advance Nicola n2.zip
  • Create New...