Jump to content
Larry Ullman's Book Forums

margaux

Members
  • Posts

    453
  • Joined

  • Last visited

  • Days Won

    52

Everything posted by margaux

  1. The error message is telling you that the password being used to connect to your database is incorrect. If you can't remember what originally set the password to be, you can change it via phpMyAdmin.
  2. Thanks Larry, any pointers re approach and database design would be great! I have 2 projects. I'd like to try doing this from scratch as I think it will be a good learning exercise. 1. Display a calendar of availability for one property. Ideally a monthly calendar will be displayed with the background colour coded to indicate available, not available, pending. This image is the general idea, http://www.google.co...,r:13,s:0,i:113 The rental fee will vary depending on time of year and length of booking. Booking period can be for any number of days, not just per week. Booking periods can begin and end on any day. The initial display will show the current month with a little arrow on the top right corner to link to the next calendar month which will then have forward and backward arrows. The visitor will be able to click the arrows to go back and forth through calendar months to check availability. Then a form will collect booking information from the user and check that the requested dates are indeed available and email the owner the request. 2. Room booking system - multiple rooms for set periods during the day. Display similar to above but by week.
  3. What have you tried? The error message is telling you that the query didn't work. Have you run it in something like phpMyAdmin?
  4. I would like to add a simple booking system to a holiday cottage site. Is this very difficult to build from scratch? I've looked for some online tutorials but haven't found any. I would like to build this rather than purchase a system, so any suggestions on how to approach this or for online help would be great.
  5. You can have 2 forms on the same page but you must differentiate the processing in some way. For both the edit and the delete processing you check for $_SERVER['REQUEST_METHOD'] == POST. Really what you want to do is have 2 different checks - one for form 1 and one for form 2. The error 'undefined sure index' is because you check for it before it has been defined. Alter the code to if (isset($_POST['sure'])) { $_POST['sure'] will only be set if it has been checked so you can then delete that record. If you try to update a record without actually changing anything you won't get an error but mysqli_num_rows will return 0 rows because no rows have actually been updated. A couple of suggestions if you don't mind: You are missing a curly brace after the first if conditional. It's really helpful if you comment your big nested ifs to quickly see where each one ends. I would suggest that you structure this as one form - having 2 forms makes the logic more complicated than it needs to be.
  6. In newbookentry.php, you could try something like if (isset($_POST['member'])) { $members = implode(", ",$_POST['member']); } else { $members='Please select a member'; } echo $members; If the data is going to be stored in a d/b, I like to give each checkbox a unique name e.g. member1, member2 etc. Then you can loop through them to identify each checkbox specifically.
  7. You can have multiple forms on a single page. In your instance, you can implement the functionality in a number of different ways e.g. include a checkbox for deletion and then your form processor can check if that checkbox isset. this method only involves one form. Post your code and specify what happens and we might be able to offer more help.
  8. this should work $q = "SELECT *, DATE_FORMAT(saved_date, '%D %M %Y') FROM saved_curtains WHERE quote_no = '$quote_no'";
  9. It's not clear what your problem is which you need to work out. What's not working? Are you getting error messages? Is your issue with sending emails from XAMPP or that you are not able to assign an email address to your variable $e? In my previous post, I suggested some code. What does 'not working' mean? When you run your script, what happens? It would help if you gave more information e.g. what does your database look like? Since we don't have the book, you have to provide this info.
  10. I can't tell if you got this to work or not. If so ignore the rest of the response. At some point in the user registration process you must have collected the user's email address? and created a record for the user which uniquely identifies him and stored his details in the d/b? For the user to change his password, he must input some details which you can use to access his info from the database including his email address. For example, if he is required to enter a password and username to change his password you can do something like $r = ($dbconn, "SELECT email FROM users WHERE username = $_POST['username'] AND password=SHA1($_POST['password']) LIMIT 1"); if (mysqli_num_rows($r) == 1) { list($email) = $mysqli_fetch_array($r, MYSQLI_NUM) } Then you can use $email in your mail() function. Not sure if the above helps, but as I don't know the full code, its difficult to know what you have to work with. I skipped a few steps, particularly security ones, so if you have any questions on the above, feel free to comment.
  11. I don't have this book so I'm not sure what data you are using to change the password. If $e is the email address of the user who is changing the password, use that in your mail: mail($e, 'Account password changed.', $body, 'From: postmaster@localhost.com');
  12. Thanks Larry - actually, there was an error in my write_session function.
  13. It's been niggling at the back of my mind for awhile as I'm sure it will come in handy at some point. Also its a good way to learn/remember functions. Thanks again for your help.
  14. I get the following error when I run the sessions.php script which includes the session handler functions line 37 is the call to session_write_close(); What does this mean exactly and how do I rectify it? Incidentally there is a session text file being saved in the tmp directory referred to - its full of data that I don't understand.
  15. Ahh thanks Antonio. I do remember reading that somewhere but had forgotten it. Hopefully I won't forget again. SUBSTRING(postcode,1,4) and its SUBSTR equivalent worked.
  16. You can use $_SESSION as a multi-dimensional array and assign values to it as you would any other array.
  17. You will need to create a script to update that column and use cron to schedule it to run automatically. There's a chapter in Larry's Advanced PHP book on scheduling jobs.
  18. Finally got some time to return to this and got it working using SUBSTRING_INDEX(postcode,' ',1) But I am surprised that both the following did not work SUBSTR(postcode,0,4) SUBSTRING(postcode,0,4) Any ideas?
  19. The second parameter for mysql_fetch_array which is optional lets you specify the type of array that is returned, either numeric or associative. Try $row = mysql_fetch_array($r); Refer to the php manual for more information on the second parameter.
  20. HartleySan posted a good link on isset, empty and is_null on another thread http://virendrachand...pty-vs-is_null/
  21. I copied and pasted the code from your first post and ran it in MAMP - worked perfectly
  22. If you are going to use $gender later in your script, you need to create it otherwise you will get an error '$gender undefined' which is not the same as $gender = NULL
  23. margaux

    Introductions

    @Benney, This forum is primarily for people learning/working in various programming languages for web development, PHP, MySQL, Javascript, Ajax and other technologies that Larry has authored books on. You can also ask general questions on these subjects. You may not find alot of threads on business ideas and problems although Larry does touch on some general concepts in his e-commerce book. If you are looking for information/discussion on programming languages and concepts regarding building web sites, you will find that Larry and many others here are very helpful and generous with their time and knowledge. Be sure to read the forum guidelines and remember that people are giving their time and knowledge freely. If someone has given you a lot of help, its nice to thank them. Happy learning
  24. That's correct. function make_full_name($first, $last) { return $name=$first . ' ' . $last; } In your calling script, call the function with the 2 arguments and store the return value in a variable. $fullname = make_full_name($fname, $lname); You can then use $fullname in the calling script to do whatever - echo to the browser, send as part of an email, insert to a database.
  25. I don't know what possessed me but I decided to try again - anyway lo and behold it worked! I got a bunch of warnings about the +VERSION file and some Riyadh timezones but have tested it successfully on 3 different timezones. I can only think that restarting the mysql server and my machine may have made a difference? Thanks again Larry for your help, really appreciate it.
×
×
  • Create New...