Jump to content
Larry Ullman's Book Forums

All Activity

This stream auto-updates     

  1. Past hour
  2. Yesterday
  3. Last week
  4. Hi Priyam, What script in Larry's book are you trying to use (and page number in the book)? Also see: https://www.w3schools.com/php/func_mysqli_num_rows.asp Necuima
  5. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\phpprogramme\project\gmail.php on line 31 please reply
  6. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\phpprogramme\project\gmail.php on line 31
  7. Hi Larry, This time it is me that is sorry re the delay in responding. I have just started changing over from Win 7 to Win 10 which is inhibiting my ability to test your proposed solution. I have a LOT of stuff on the Win 7 PC so am taking it very carefully - bit by bit - as I make the change to the (separate) Win 10 PC. Also am making the change from Windows Live Mail to Outlook and that's not as straight-forward as one might imagine especially as I want to migrate all my email storage folders over to Outlook. I will test your suggestion as soon as I can but it might be a couple of weeks before I can - and please accept my apologies for my tardiness. Cheers from Oz.
  8. Ah, cool! And thanks for sharing your learning experience. If it helps, I still make dumb mistakes, too.
  9. Hi all, Well, finally solved it. What really complicated matters was that my browser was converting the (correct) answer from php back to html entities! This led me to believe that php wasn't actually doing anything. So, it has all come down to two lines of code:.... $search = trim($_POST['Search']); $search = htmlentities($search); Now, php can do the MySQL search and now finds matches. To get round the problem on the test script I added as the first line: header('Content-Type: text/plain'); .....so now my test script works as well. Best regards and thank you, Larry. Max
  10. Yes, I think you are correct. I was looking at that last night and noticed that a lot of those records had the same reg date because I pasted in your SQL in phpMyAdmin and ran it that way. I was monkeying around with XAMPP this morning and needed to add the Mercury mail server. In XAMPP, if you don't install everything the first time, you have to uninstall and reinstall choosing everything. The installation program will not let you choose an install directory that is not empty, so, I had to uninstall everything. In the process I forgot to backup the databases I created so far in the book! Yikes! So, I am starting over from scratch. I may just enter those user records in manually one-at-a-time so they have different reg dates. Oh well, my mind is slipping. I'm getting old and should have know better, but hey, it's only development now.
  11. I'd check the registration date. It's likely that multiple records have the same value there if they were created by a mass import.
  12. Earlier
  13. I'm in Chapter 5 Introduction to SQL and working through some of the SQL queries to get a feel for doing this. I ran into some unexpected results while using the LIMIT x,y statement. First I ran the query: SELECT first_name, last_name FROM users ORDER BY registration_date ASC; And I go back this result set: MariaDB [sitename]> SELECT first_name, last_name -> FROM users -> ORDER BY registration_date ASC; +------------+-----------+ | first_name | last_name | +------------+-----------+ | Larry | Ullman | | Zoe | Isabella | | Ringo | Starr | | George | Harrison | | Paul | McCartney | | John | Lennon | | Michael | Chabon | | Richard | Brautigan | | Russell | Banks | | Homer | Simpson | | Marge | Simpson | | Bart | Simpson | | Lisa | Simpson | | Maggie | Simpson | | Graham | Greene | | Don | DeLillo | | Jonathan | Franzen | | David | Jones | | Peter | Tork | | Micky | Dolenz | | Mike | Nesmith | | David | Sedaris | | Nick | Hornby | | Melissa | Bank | | Toni | Morrison | | Abe | Simpson | +------------+-----------+ 26 rows in set (0.00 sec) Then I ran the query: SELECT first_name, last_name FROM users ORDER BY registration_date ASC LIMIT 1,1; And this is the result set: MariaDB [sitename]> SELECT first_name, last_name -> FROM users -> ORDER BY registration_date ASC -> LIMIT 1,1; +------------+-----------+ | first_name | last_name | +------------+-----------+ | Zoe | Isabella | +------------+-----------+ 1 row in set (0.00 sec) As expected, I get back the second row and just return that one row since Zoe Isabella is the row at index 1. So, I tried to return just Ringo Starr. He is at index 2, so, I need LIMIT 2,1. Ok SELECT first_name, last_name FROM users ORDER BY registration_date ASC LIMIT 2,1; But I don't get Ringo, I get this: MariaDB [sitename]> SELECT first_name, last_name -> FROM users -> ORDER BY registration_date ASC -> LIMIT 2,1; +------------+-----------+ | first_name | last_name | +------------+-----------+ | Paul | McCartney | +------------+-----------+ 1 row in set (0.00 sec) What is going on? Paul is suppose to be at index 4! Any Ideas?
  14. Ah, sorry about that but kudos for figuring it out and thanks for letting me know!
  15. Hi Larry, html : <meta charset="utf-8"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> MySQL: Collation on all relevant columns and tables are utf-8_unicode_ci When I use phpMyAdmin the accented characters show as ASCII entities (i.e. á = &aacute;), which is what I want. It all works fine: Inauguraci&oacute;n. Bendici&oacute;n de las locomotoras - &Aacute;guilas. Marzo 1890. - from phpMyAdmin becomes..... Inauguración. Bendición de las locomotoras - Águilas. Marzo 1890. The entities in MySQL have been converted to accented text as wanted. The problem seems to be that php isn't recognising the accented characters and thus not converting them to ASCII entities for the search engine that I am trying to create. Thanks as always for your time and help.
  16. Hi Mr. Ullman and Abigail, I solved the problem. Actually it was an error in the original code after all. So I've found something that should go in the Errata of the book. Specifically, on the GitHub page for the book, it is in: the ch18 code --> the html folder --> the includes folder --> the header.html file. It's line 20. That line says: <link rel="includes/layout.css"> Instead it should be: <link rel="stylesheet" href="includes/layout.css"> The error is found in the book itself in Chapter 18, on page 588, in Script 18.1, in the <head></head> section. Best Regards, John Iatropoulos
  17. This kind of problem is a PITA to debug b/c it could come from several places: the value stored in the database, the value retrieved from the database, the value put into the HTML, or the value displayed in the browser. I don't think you want to go to some converter method; it's best to solve the actual problem. I'd start by confirming how the values are stored in the database. Make sure the database is using UTF8 everywhere, especially on the specific table and column. Make sure you're using UTF8 when connecting to the database, both directly and from PHP. And then make sure your HTML page uses UTF8, both in the HTML encoding and in the encoding used by your IDE/text editor when saving the file.
  18. Sorry about the delay and thanks for reminding me! The solution here isn't immediately obvious so I had to hunt around a bit. It looks like the write session function is what comes into play here (per the PHP manual), but that method returns true, assuming we're looking at the same script. This is a wild guess, but does it get fixed if the close session function is changed to mysqli_close($sdbc); return true;
  19. Probably your code is not finding the CSS files but I don't have time to look into it for you. Find out where the files are and where your code is looking for them.
  20. Hello Mr. Ullman, I am a big fan of your work. I have owned your book PHP and MySQL for Dynamic Web Sites, 5th Ed. for a while now, but I've never actually posted a question on this website before. It's great to finally make your acquaintance! My question is sort of an unusual one. I attempted to get the web application/ website from Chapter 18 of PHP and MySQL for Dynamic Websites, 5th Ed. up and running on a remote web host (I use ChemiCloud as my host, which is a company like Bluehost). It was almost totally successful. All the sophisticated PHP functionality works - the user registration, the user activation, the user login, etc. The only thing is ... you'll never believe it ... the CSS doesn't work for me. It's this simple, foundational kind of issue. I'm sure it's not something wrong with your code. It must be something wrong on my end. I don't get any error messages. It's just that the website does not look right. It must be the CSS, because when I look at any of the pages of the website, it looks like bare HTML without CSS, and all the navigation bar links (from footer.html) are not on the right of the screen as it shows on page 588 of your book. Instead the navigation bar links are on the bottom of the screen. If you want me to post or send a screenshot, just tell me. I got the code files from GitHub. I set up the code files on my web host exactly the way you have them organized on GitHub. Most of the files I put in my public_html folder, except for the 4 files that I put in an includes folder within my public_html folder. Those 4 files are: config.inc.php, footer.html, header.html, and layout.css. The only way that I departed from your organization of the code files is that I put the mysqli_connect.php file in the includes folder, and not in the folder that is above the public_html folder. (The reason is that ChemiCloud told me that on their system I am not able to put anything in any folder higher than the public_html folder.) Then I went into all of the files that reference the mysqli_connect.php file, and edited the references so that it would refer to includes/mysqli_connect.php. There might be something I'm overlooking, but I really did try to solve this problem on my own before I posted. I searched on this forum for any posts on CSS, and could not find any. I looked at the layout.css file, and everything looks okay. I looked at the header.html file (Script 18.1, on page 588), which contains the code: <head> <meta charset="utf-8"> <title><?php echo $page_title; ?></title> <link rel="includes/layout.css"> </head> and everything looks okay. My web host runs PHP version 7.0.33. But based on what you say on page xii of your book, that's probably not what's causing my problem. On page 4 of your book, you say that the HTML version is HTML5. I don't think you say it in your book, but I assume that the version of CSS is CSS3 or CSS4. I use a Lenovo laptop for my web development, running Windows 7, 64-bit. If you want more info about my remote web host, tell me. Thank you for your time and help. Best Regards, John Iatropoulos
  21. I have come across htmlentities and htmlspecialchars but neither seems to work. Here is a Q&D test: <?php if(isset($_POST['char'])) { $char = $_POST['char']; $char2 = htmlentities($char); echo 'Answer: ' . $char . '<br /><br />'; echo $char2; } echo '<form action = "char_test.php" method = "post"> <input type = "text" name = "char" size = "6"> <input type = "submit" name = "submit" value = "Search!" /> </form>'; if I entered á then I would expect the answer to be: Answer: á &aacute; but I get: Answer: á á This goes for all of the characters that I have tried. Surely php wouldn't put something in their manual that doesn't work?
  22. Hi Larry and everyone, I'm still using your book as php is still reducing me to tears. Here is the problem: I have created a large database in English and Spanish. In spite of setting the MySQL db to UTF-8 it still returns nonsense characters with eg accented 'a', so I have been entering all of the text with accents as for example á = &aacute;, Ú = &Uacute;, ñ = &ntilde; as the only way to guarantee that they print correctly when called. The problem is that when a Spaniosh speaker does a search, then they will search for eg 'Estación' not 'Estaci&oacute;n. The php if conditional doesn't recognise accented characters so I need to parse each word letter by letter and convert any accented character to its ASCII decimal to then convert it to the ASCII entity i.e. 'á' => &225; => &aacute; to present to MySQL. I can't find a converter in the turgid php manual so am stuck. I have re-read your chapter 'Making Universal Sites' but have now resorted to coming home to daddy. Thanks Max
  23. Thanks very much, I am reading a javascript book and is pointing me towards the right direction. If I need any further assistance on this I will post it in any javascript forum. but I'm still coming with a lot of questions on php when I am through with reading PHP and MySQL for Dynamic Web Sites, Fifth Edition
  24. I don't know the answer to this one off the top of my head. You might be able to use imagmagick or gimp? I really don't know whether this would qualify as OCR or not? I imagine you'll need to find some software that runs on the server that can do the work, then upload the image via PHP and call the software via PHP through an exec() command. None of this would be easy or obvious. If you already have a JS library that works for the reading of the image, can't you just have JS do the math, too?
  25. Hi everybody, I want to write a php code that extract numbers say 4567 from an image when you press scan button and then sum the numbers together. I have used one javascript library but I'm having problem in converting the numbers into an array. pls. I need an help urgently.
  26. I'm not quite following the use case here (why you'd update a table to an auto-increment value) but, more importantly, this isn't a prepared statement? Could you provide a bit more code? Also, when you say you're having a problem, what is happening that shouldn't? Are you seeing any error messages?
  1. Load more activity
×
×
  • Create New...