Jump to content
Larry Ullman's Book Forums

fumble

Members
  • Posts

    8
  • Joined

  • Last visited

fumble's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks Larry Lock down fickness. It's a thing! ....so, as an example, using script 9.7, p293 (in my book), line 43..... $q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p')) "; Are you saying that this could/should be written as.. $q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p')) " - without the ending semicolon? Thanks again.
  2. Hi Larry "You should not end your queries with a semicolon in PHP, as you do when using the mysqli client........." Undoubtedly I'm being really fick, but I'm struggling with the above? I've searched for examples of this advice in script 9.3, but to no avail. It's from the top TIP in the second column, p280. Any help much appreciated. Warm Regards
  3. Thank you so much for your reply HartleySan. Things becoming clearer now. In hindsight, I may have misled unintentionally with the wording of the second question. However in saying that each image tag requires a separate HTTP request, you have answered the question I meant to ask! I think I know how to proceed now. As an observation, msg board pages with very many posts must create a huge amount of traffic between browser and image folders? And as for photo galleries.....?!! Thank you again.
  4. Hi I transferred my site to a hosted Server recently and the issue of displaying images - user avatars associated with forum posts ( avatars are located in an images folder outside of the root directory ) - reared it's head. Previously, on my local host, I accessed the users avatars using code similar to the following: $thumb = '<img src="../uploads/avatar.jpg">'; Following much heartache, I now realise ( as highlighted in CH.11 ) that a user's browser cannot access a file which is outside of the root folder. As Larry points out, a proxy file is required. My questions are - A. On first reading, it seems I will need to invoke the header() function to find each image. However, this function would be required quite a way into my particular show_forum_posts.php script. Larry says the header() function MUST NOT be preceeded by any other characters...... ????? I don't know how to resolve this. B. Each forum post in a particular thread, and the associated avatar for the poster, is sourced using a SQL query and a while loop. What is the most efficient way ( in plain language ) to structure the solution? Is it better to collect all the avatar details for a particular forum page in one go, so that the user's browser can somehow make one visit to the images folder and find the required avatars, or is the browser destined to make multiple visits to the folder, one visit per avatar image? Without knowing why, it would seem to be a much slower process if this were the case, and potentially damage site performance. Hope all of the above makes sense. Many thanks for any advice and tips.
  5. Thank you Antonio. I will have to revisit my understanding - or lack thereof ! - of joins. I have managed to date using the AND expression to join tables, but your example is the way forward. I'll have a go at rewriting my query. Really appreciate the help.
  6. Hi all. I have designed a forum ( with great help from this book - thanks Larry ) which seems to be working well. One thing still bugs me though. I have a table for forum threads which contains among others, the following two colums: thread_originator_id and last_reply_poster_name. Ideally I would like to have both columns contain each forum user's ID ( numeric ). However, I can't write the Query ( believe me, I tried - for days! ) which returns both users names ( using a join between two tables - users and threads_forum ). CONCATing one user is easy, but two ?? As a temp fix, I turned the last_reply_poster_name column into a varchar column and stored the person's name, which still gives me sleepless nights - horrible programming! My code is like this. $q3 = "SELECT CONCAT(first_name,' ',last_name) AS thread_starter_name, thread_title, thread_main_forum_id, DATE_FORMAT(date_thread_started, '%a, %e %b %y, %H:%i') AS date_thread_started, DATE_FORMAT(time_last_reply, '%a, %e %b %y, %H:%i ') AS time_last_reply, num_replies, thread_originator_id, last_reply_member_id, last_reply_poster_name, last_reply_post_id FROM threads_forum, users WHERE forum_sections_id = '$sid' AND group_id = '$gid' AND user_id = thread_originator_id ORDER BY last_reply_post_id DESC "; So, I would like to be able to write a query which CONCATS both names using the two user IDs - thread_originator_id and last_post_reply_user_id. ( There are other ways in which to solve the problem - redesigning the tables for one, but I'm interested in a properly written query to the above problem. ) Many thanks in advance.
  7. Hi everyone. I'm new to the forum. Just about finished the book. Fantastic read and thus far, has been one of the best learning experiences of my life. Many thanks Larry. One question I have relates to this topic. Perhaps someone could give a helpful analogy to better explain ( to me ) the meaning behind 'saving server resources' re: mysqli_free_result(); Specifically, if a particular php script has several separate database queries, if one uses this function appropriately after each query, are the results of each query useable at the end of the script, or are the results lost when you free the result? I know I could test the scripts to see how they behave, but armed with a bit of knowledge prior to testing would save time and potential frustration. Many thanks in advance.
×
×
  • Create New...