Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Emilie

  1. Hello, On this line, why are you using quotes and concatenation? if (isset($_POST['SiteTypeID']) && ($_POST['SiteTypeID'] == '. $key . ')) echo 'selected="selected">'; I hope this helps, Emilie
  2. Hello, Nick, This is exactly what you should NOT do in order to run a PHP file. Firefox is just a browser. It knows how to open and display the contents of HTML files, but on its own it doesn’t know what to do with a PHP file. For Firefox, a PHP file is just a text file, or a HTML file if your PHP is inside a HTML file, which is why it displays everything in this file, including your PHP code. For your PHP code to be run as such, the PHP file must be sent to your local server (XAMPP), where the PHP interpreter will parse the code and send it back to Firefox (as HTML), for Firefox to di
  3. I’m sure it is beneficial! And I hope I’ll see the light some day. ;-)
  4. Thanks for the tip. I’ll try this in my own projects! In theory, I agree. But I don’t know why, absolute paths usually don’t work for me for URIs. Absolute URLs work fine, absolute URIs don’t, and I really can’t understand why.
  5. Hello, hwadler, Paths are one of the real pains of web programming! Your best bet is to create constants for the different paths you will need for your projects. Let’s say my files are organised like this: root_folder index.php includes // I actually use another, less obvious name config.inc.php header.php navigation.php footer.php css styles.css images js pages_folder some_page.php sub_folder some_other_page.php I define the following paths : if ($_SERVER['HTTP_HOST'] == 'localhost:8888') {
  6. Hello, I understand. In order to avoid this kind of problem, just use the 'code' tags: the icon is in the middle on the bottom line and looks like this: < > It will also apply syntax coloring, which helps read the code. I hope this helps, Emilie
  7. Hello, You repeatedly used semi-colons instead of ampersands in the URLs : echo '<a href="view_users95.php?s=' . ($start - $display) . ';p=' . $pages . ';sort=' . $sort .'">Previous</a> '; Check all your URLs! I hope this helps, Emilie
  8. Hello, Another typo: ContractWitnessed='0, The closing quotation mark is missing. Also, if your ID is numeric, you should not quote it: where (ID='23') If this doesn't do the trick, I would suggest testing a few lines only at a time, until you find where the query goes wrong. I hope this helps, Emilie
  9. Hello, There's a typo in the line you highlighted in red: you forgot the concatenation dots around $image[3]: echo "<div align=\"center\"><img src=\"images?image=$pid&name=" . urlencode($row['image_name']) . "\" . $image[3] . alt=\"{$row['print_name']}\" /></div>\n"; I hope this helps, Emilie
  10. Hello, MySQL doesn't 'know' the variables you created with PHP. In order to test your query, you need to replace the variables with their values. I hope this helps, Emilie
  11. I see what you mean. I hadn't thought of that, because I'm not concerned with the book being viewed from the web, at least for the time being. I only needed some means of opening those huge HTML files and editing them. I'm just an amateur programmer, so I first tried to open this 70 MB file with my usual text editor (BBEdit), and although I've been able to edit a 350 MB file with BBEdit (although very, very slowly), I couldn't open this 70 MB file with BBEdit. I was going through Larry Ullman's "Advanced PHP" book at the time, and through chapter 12 more specifically, so I just thought I w
  12. Not all that insane since it represents a whole book and 7 MB was before minimizing the file. Look at the digital versions of computer books, and you'll see they are 10 to 50 MB. The HTML file is the largest file within an ebook format (ePub, mobi, etc.).
  13. Hello, HartleySan, This 70 Mb HTML file was probably created with Word or some other unsuitable application. Hence loads of unnecessary style attributes inside HTML elements, empty div elements, duplicate links (some appeared up to 20 times on one line). After "cleaning", it became approximately a 7 Mb file! Emilie
  14. Hello, I think you can leave them as they are for now. If there are exercises where you need the registration date, you can change the registration date for some of them then, or add users so as to have a diversity of registration dates. Emilie
  15. Hello, What is "wrong", according to you? The registration date is the same for all users because you entered all of them at one go into the database, and therefore the timestamp corresponding to NOW() is the same for everyone. Because of that, ordering the results by registration_date DESC has no real meaning. I hope this helps, Emilie
  16. Hello, These lines make the dropdown menu and the radio buttons sticky. For $_POST['efficiency'] to be set, the form must have been sent and the user must have chosen one option in the dropdown menu. So, if the form has already been sent but the user forgot something (either 'distance' or 'gallon_price') and the partially completed form is printed again... if (isset($_POST['efficiency']) && ($_POST['efficiency'] == '30')) ... first checks that the user chose one option in the 'efficiency' dropdown menu (isset($_POST['efficiency']), and if the chosen value is '30' the PHP scr
  17. What you want to do is to check if $_POST['newsletter'] is set AND if the value of $_POST['newsletter'] is 'yes"; if that's not the case, you want to check if $_POST['newsletter'] is set AND if the value of $_POST['newsletter'] is 'no"; the final 'else' doesn't change. I hope this helps, Emilie
  18. I only need that much memory to start with because these HTML files have been compacted and made into 1 line only. Once I've introduced line breaks, I can use file() to create an array of lines, and then use a foreach loop. This 70 Mo HTML file is also buggy, which is probably why BBEdit can do nothing with it, since it previously managed to introduce line breaks into a 350 Mo HTML file. But it took something like 20 minutes, whereas it only takes 1 or 2 minutes from the command-line!
  19. Thank you very much, Antonio Conte. You've answered all my questions. The php.ini file is in /etc, and I should have known, because I think Larry mentions it in his book. The script now works, but I had to allow 512 Mo memory. The default setting was 128 Mo, it wasn't enough; 256 Mo wasn't enough either. 512 Mo did the trick.
  20. Thank you for your answer, Larry. The PHP script is only 4 KB, but the HTML file is indeed 70 MB (it's a HTML file with lots of unnecessary styling inside). And I can't go through it a line at a time because it's one huge line! That's part of what I need to change. My text editor (BBEdit) managed to add new line breaks in a 300 MB file, but this 70 MB HTML file is buggy, so BBEdit cannot do anything with it. That's why I'm trying to find other ways of editing it. I can open it and read it without any problems in the command-line, I just need more memory to be able to add new line breaks a
  21. Thank you very much for your answer. I feel very stupid, but where can I find the php.ini configuration file for PHP CLI? I know this version of PHP is in /usr/bin, but I see no php.ini file there: And the php-config file is a Unix executable.
  22. Hello, I'm new on this forum. I'm an amateur and intermediate web developer. English is not my mother tongue, so I apologize for all the mistakes I'll make in my messages! I've been reading chapter 12, 'PHP's Command-Line Interface' and have had no problem reproducing the different scripts. But now I'm trying to apply what I've learnt to other PHP scripts, and I've run into a fatal error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 70517676 bytes) in some_file.php on line 7 Line 7 is the following: $clean_file = str_replace('some_string', '', $
  • Create New...