Jump to content
Larry Ullman's Book Forums

All Activity

This stream auto-updates

  1. Earlier
  2. Thanks for your interest and sorry for the delayed reply. Right now there's no plan to update the PHP Advanced book. I've not even spoken with the publisher about it. Thanks again, though, for asking!
  3. Just wanted to know, if there is going to be a new edition of this book in the near future and if there is, when will this book be out, please let me know. Best Regards, Fred
  4. Hi Larry, Regarding your spam blocker, of course, I have been using it. However, I was still getting emails from automated spam producers, bots or whatever, so I thought I would share this little routine with you. It simply checks to see if there is a human at the other end (who can add!!) and I now receive NO spam at all. All I do is ask the customer to add two numbers. I put these as numerics, but one could create an array with 1 = One, 2 = two etc etc. I'll leave out all of the extraneous code. Header etc etc <?php $check = $_POST['check']; //Getting answer from customer of the addition. $result2 = $_POST['checking']; //Getting answer from the addition by the server. //if then loops etc, with all of the questions etc.... //...after spam scrubber: if($check == $result2) { //Send the email to me and thank customer } else { echo '<h2 style = "font-family: Arial, Verdana; font-size: 20px; font-weight: bold; background-color: #ffff99;">It seems that your arithmetic is erroneous. Please try again.'; //Make the customer do the sum again. } ?> //Start form action..... Check:<br /> //Or you could write more informative text for the customer. <?php $random1 = RAND(1, 9); //Invent an integer between 1 and 9. $random2 = RAND(1, 9); //Ditto. $result1 = $random1 + $random2; //Do the math!! echo 'What is ' . $random1 . ' plus ' . $random2 . '? <input type="text" name="check" size="3"/><input type = "hidden" name = "checking" value = "' . $result1 . '" /><br /><br />' ; //Ask the customer the question - the answer to the addition. Also send the server's answer ($result1). ?> <input type="submit" value="Send" ><input type="hidden" name ="Secure" value = "ejeewq8"> <input type="reset" value="Clear"> <input type = "hidden" name = "submitted" value = "submitted"> //Send it. <br /><br /> I hope that you find it interesting. Regards Max
  5. If you just google "xampp mail server windows" you'll find plenty of tutorials on the subject. (I don't have XAMPP on Windows, so I don't know off the top of my head.)
  6. Thanks larry since i do not have local mail server, can i use php.net mail server ? [mail function] ; For Win32 only. ; http://php.net/smtp SMTP=localhost ; http://php.net/smtp-port smtp_port=25
  7. From there error messages, you have two issues to resolve. The first is you haven't configured a local mail server. The second is your error handling script still references the $e_vars variable, which it no longer has defined as an argument.
  8. Hi Larry, Thanks for your responding. I have removed the last parameter from my_error_handler() when i run again http://127.0.0.1/phpmysql4_scripts/ch18/html/register.php User Registration An error occurred in script 'D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php' on line 70: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() Date/Time: 9-17-2021 23:23:14 Warning: Undefined variable $e_vars in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 54 #0 my_error_handler(2, mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set(), D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php, 70) #1 mail(wongkinping@chinalifeagt.com.hk, Registration Confirmation, Thank you for registering at . To activate your account, please click on this link: http://127.0.0.1/phpmysql4_scripts/ch18/html/activate.php?x=wongkinping%40chinalifeagt.com.hk&y=a331f2faab5825188d23eca77974f18f, From: admin@sitename.com) called at [D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php:70] Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account. sorry for any simple question, but I am new to PHP. Thanks Andrew
  9. There are two issues here. One is that there's an error going on in the script. The second is the error handling isn't working properly. For the latter, you don't mention what version of PHP you're using, but I expect the warning in the box applies: https://www.php.net/manual/en/function.set-error-handler.php Remove the last parameter from the my_error_handler() definition, as well as the use of that $e_vars variable within it. Once you fix that, you should properly see the actual error that's happening on the page.
  10. User Registration Fatal error: Uncaught ArgumentCountError: Too few arguments to function my_error_handler(), 4 passed and exactly 5 expected in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php:38 Stack trace: #0 [internal function]: my_error_handler(2, 'mail(): Failed ...', 'D:\\xampp\\htdocs...', 70) #1 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(70): mail('trandrew8@gmail...', 'Registration Co...', 'Thank you for r...', 'From: admin@sit...') #2 {main} thrown in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 38
  11. http://127.0.0.1/phpmysql4_scripts/ch18/html/register.php User Registration Fatal error: Uncaught ArgumentCountError: Too few arguments to function my_error_handler(), 4 passed and exactly 5 expected in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php:38 Stack trace: #0 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(10): my_error_handler(2, 'require(../../m...', 'D:\\xampp\\htdocs...', 10) #1 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(10): require() #2 {main} thrown in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 38
  12. MariaDB [ch18]> CREATE TABLE users( -> user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, -> first_name VARCHAR(20) NOT NULL, -> last_name VARCHAR(40) NOT NULL, -> email VARHCAR(60) NOT NULL, -> pass CHAR(40) NOT NULL, -> user_level TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -> active CHAR(32), -> registration_date DATETIME NOT NULL, -> PRIMARY KEY (user_id), -> UNIQUE KEY (email), -> INDEX login (email, pass) -> ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(60) NOT NULL, pass CHAR(40) NOT NULL, user_level TINYINT(1) UNSIGNED NOT NUL...' at line 5 MariaDB [ch18]>
  13. Glad that's working for you and thanks for letting me know about the emails. I'll look into it. Cheers!
  14. One more comment, Larry - I don't seem to be getting any messages via email regarding replies to topic. I have checked settings, email address etc. Not going into Spam. Thought I'd let you know. Max
  15. Hi Larry, That's what I would normally do, but I was copying and pasting a lot of data from my Garmin GPS text dump and didn't think about it at the time. Forewarned is forearmed...or whatever! Sadly, this is what passes for fun for me 🤪.
  16. Larry, you're a star! Firstly, it didn't cross my mind about 'Date' being a keyword in SQL!! I have now resolved the issue - code below. The results can be seen here: http://www.zrm.es/blog.php Yes, I know that my CSS is shocking, but I am just a hobbyist, not a professional and just hate it!! Interestingly, experimenting I can't get date_format() in php to work at all. No matter. I won't use it again. Thanks again, Larry. --------------------------------------------------------------------------------------------------- <?php $_title = "blog."; $_description = "blog"; $keyword = "blog"; include ('header.php'); require_once('../users.php'); //This is the $dbc routine. ?><br /><br /> <div style = "width: 80%; margin: auto; "> <p style = "margin: auto; border: 6px solid rgb(62,60,100); width: 15%; height: 30px; padding: 1.8% 0 0 0; text-align: center; font-family: sans-serif; color: rgb(62,60,100); background-color: rgb(255, 204, 0); font-weight: bold; ">BLOG</p> <br /><br /><br /><table style = "border: 3px solid rgb(62,60,100); width: 99%; "> <?php date_default_timezone_set('Europe/Madrid'); //actually in header.php as well - put this in out of dessperation. $blog1 = "SELECT * , DATE_FORMAT(Date1, '%W, %e %M %Y') AS 'FD' FROM ZRM ORDER BY Date1 DESC"; //SQL request including the formatted date $blog2 = @mysqli_query($dbc, $blog1); //Do the query while ($blog3 = @mysqli_fetch_array($blog2)) //while loop to extract the data from the array { $ref = $blog3['Ref']; //Dont really need this but hey $date1 = $blog3['FD']; //Formatted date $comments = $blog3['Comments']; //Text $image = $blog3['Image']; //image name echo '<tr><td><a href = "images/raw/' . $image . '.jpg" target = "_blank"><img src = "images/reduced/' . $image . 'jpg" alt = "Sorry, image missing." title = "Click to enlarge." style = "border: 2px solid black; margin: 5px; margin-top: 5px; margin-bottom: 5px; margin: auto; " /></a></td><td style = "padding: 5%; vertical-align: top; "><p style = "vertical-align: top; text-align: right; "><b>' . $date1 . '</b></p><br /><br /><p>' . $comments . '</p></td></tr>'; } echo '</table></div>'; include('footer.php'); die(); ?> ---------------------------------------------------------------------------------------------------
  17. My inclination is it's either not being stored or retrieved in a format that PHP can use. I'd check/confirm your column type. Also, it's best not to use "Date" as a column name since it's also a keyword in MySQL. That being said, I'd have MySQL return the data in the format you want, rather than ask PHP to convert it.
  18. Hi Larry, Thanks for your reply to my problem with splitting numbers and alphas. I have a new problem now and am baffled. I am putting together a little blog for which I am using MySQL and php. The database is populated fine and I can pùll the date as $date from the MySQL, The problem is when I try to format it as, for example, Monday 27 July 2021. The code is: Previous code includes calling $dbc, etc etc. <?php date_default_timezone_set('Europe/Madrid'); $blog1 = "SELECT * FROM ZRM ORDER BY Date DESC"; $blog2 = @mysqli_query($dbc, $blog1); while ($blog3 = @mysqli_fetch_array($blog2)) { $ref = $blog3['Ref']; $date = $blog3['Date']; It all works up to here: $date2 = date_format($date, 'd/F/Y'); echo date_format($date, 'j n y') . $date2; As you can see, I have tried a number of formats. Nothing at all prints and no error messages. Using double apostrophes neither. $date prints as: 2021-09-13 13:33:06 . The strange thing is that I can copy/paste the code into W3Schools and it works perfectly (by adding a line at the top: $date=date_create("2013-03-15"); See https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_date_format For example, W3Schools gives me: 13 Sep 2021 when I run: <?php $date=date_create("2021-09-13 13:33:06"); echo date_format($date,"d M Y"); ?> If I have to I can use some string functions to pull the date apart and re-organize it, but date_format should work, no? As always, your assistance is greatly appreciated. Max You can see $date as it comes out here: http://www.zrm.es/blog.php
  19. Hey Max. Kudos for figuring it out and thanks for sharing the solution. The first thought that came to my mind would be to store the coordinates in separate columns. In other words, split the coordinates upon receipt and then store them in two columns. That'll make future work easier to do.
  1. Load more activity
×
×
  • Create New...