Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. I don't think you want to use HTTP_REFERER. For one, you're not guaranteed that it will have a value. Two, HTTP_REFERER refers to the previous site the user was on. So, if I came here from google, HTTP_REFERER (if it had a value) would be http://www.google.com. If you're trying to do what I think you want, you instead need to use query strings. If you have a url like: www.site.com/index.php?p=news The part starting at the '?' is known as a query string. You can grab its value by using the $_GET[] superglobal array, like so: $page = $_GET['p']; // $page now contains 'news' Obviously, you'd need to ensure that: 1. 'p' exists 2. it doesn't contain bad/dangerous data But that's the general idea. To make that work with a 'pretty' url, like: www.site.com/news You'll need to write a .htaccess file with the appropriate mod_rewrite rule(s). I suck at writing those, so someone else can address that part of it.
  2. @joshspaulding Can you show us some of your code? Also @computermax2328: I wouldn't recommend that just yet. Newbies often treat frameworks as a crutch that allows them to not learn the underlying language. I get that you mean it as something to do later on in the OP's journey' date=' but many newbies read it as, "I can get better results without wasting time on the boring crap? Awesome!" Ugh, bad idea. WordPress is an utter wreck under the hood, and is essentially a big anti-pattern. It is not the way any modern app should be structured or written. It works, and does the job if all you want to do is slap something together and call it a day, but as a learning tool? No.
  3. Unless you're experiencing lag, or you're really concerned about mobile devices, I wouldn't sweat it. Just try to keep the number of hits to the server to a minimum. I'm not an expert in mobile development (just getting into it myself), but there are techniques that can help. For example, only showing one image if the display area is a certain size, and injecting the slide show code and dynamically loading the other images if it's above that. This book (http://www.abookapar...sive-web-design) goes into it in detail.
  4. Yeah. The downside is refreshing the entire page when all you want is a slide show. Where did you find your slide show scripts? Most modern scripts are fast. Also, have you optimized your images? Do they need to be 65kb each?
  5. This forum is for website critique, not code review. Further, no one here tends to look at file attachments for a variety of reasons - security, not wanting to read through multiple files, etc. Your best bet to receive meaningful replies is to post specific questions/issues in our Application Design section with relevant code (within tags).
  6. You shouldn't be using the old mysql_* functions at all. They've been soft deprecated. Instead, use either MySQLi or PDO with prepared statements. That will protect you from injection attacks.
  7. Your code doesn't make any sense. What are you trying to do? Do you have any real code to show?
  8. 1. How are you qualified to write a math book aimed at children? Do you have a math degree? A degree in early childhood education? 2. What separates your book from the host of others already on the market? 3. Where's proof of your ability to actually make something like this? Successful Kickstarter projects start with a workable prototype or demo. Aside from a handful of (admittedly) cute monsters, where's the beef? It's a noble goal, but aside from a handful of character illustrations and a hastily cobbled together static website, there's nothing to indicate that you're capable or qualified to deliver on your idea. It doesn't matter that you're only asking for $5,000. If you're asking people for their money, you have a moral obligation to do everything in your power to prove that their investment will go to a worthwhile product that will meet expectations and will be delivered.
  9. Like Jessica said, this: Doesn't make any sense because the employees already exist in the database, and the results that pop up on the screen when someone enters a particular number is the output shown. Are you just trying to log what employees are being looked at with the most frequency? Are you simply trying to list all employees in a table? And if the website is displaying employee info, then you do have database access.
  10. Do you know how to use $_GET[]? Do you know how to create a hyperlink?
  11. Regarding in-place text editors, there are plenty you can find and use. TinyMCE, CKEditor, etc. I'm not sure what we're using as it's part of IPB's software. Philip would know.
  12. You need to explain as clearly and concisely as you can what you're trying to do and how you're trying to do it. That includes: 1. What you expect an incoming URL to look like 2. Your current DB structure Right now, you're blindly throwing code at the problem without any sort of understanding behind it. Programming doesn't work like that.
  13. This line of code: $userid = (int) $_GET['userid']; Does the following: 1. It assumes a query string like www.example.com/index.php?userid=something 2. It grabs the 'userid' portion with $_GET['userid']. At this point, if the query string exists with userid, $_GET['userid'] will contain something 3. The (int) portion casts (transforms) the something contained in $_GET['userid'] into an integer 4. That new integer version of something is then assigned to (stored in) a variable named $userid So, asking me whether casting LessonDate as an integer misses the point. Are the values in your LessonDate database column stored as integers? Do you want the incoming data to be turned into an integer?
  14. Are you certain that a listing with the lesson date in question exists in your database? Or that the lesson date passed in is in the right format? Have you tried running the query in phpMyAdmin?
  15. You need to put all of your delete code in the if-conditional: include('../../config.php'); $LessonDate = ""; if (isset ($_GET['LessonDate']) ) { $LessonDate = $_GET['LessonDate']; mysql_query("DELETE FROM `booking` WHERE `LessonDate` = '$LessonDate' ") ; echo (mysql_affected_rows()) ? "Row deleted.<br /> " : "Nothing deleted.<br /> "; } The brackets {} denote a block of code. In this case, it means that everything within them will only be executed if the query string value LessonDate is set. With your original code, your placement of the brackets meant that $LessonDate was being assigned if the query string was set, but the actual MySQL query and subsequent echo were happening regardless. Now, all of it depends on whether or not the query string is set. If it's not, no deletion will happen. For more info, read the manual: http://php.net/manual/en/control-structures.if.php
  16. iPhone apps are written in Objective-C.
  17. Unfortunately, it's not working because PHP is treating your first value, the 0, as boolean false, so it's skipping the entire loop. Change it to 1 and see for yourself. Regardless, you're better off sticking with foreach() loops, which is generally the convention when looping through arrays.
  18. The first thing you should do is figure out what problem your site is trying to solve. Every website has a purpose, and within that purpose you can figure out the important data and behind-the-scenes processes that addresses that purpose/problem. From there, flip it around and figure out how an end user would want to interact with that. Unless you're doing something incredibly simple, chances are what your users can interact with will be a small portion of what actually happens on the back end. Refine and repeat that process until you're confident you have something coherent.
  19. To be honest, you should slow down and be competent in the fundamentals before using a framework. Frameworks should never be used as a shortcut to learning.
  20. Symfony's documentation also leaves much to be desired. Most of the problems I've had have been due to the docs being incomplete, or outright incorrect. Good framework, but Fabpot needs to keep the development side of things in synch with the docs.
  21. You keep saying we haven't offered proof. When we offer proof in the form of w3fools.com, you then shift the goalposts by dismissing it as not being valid/not having any weight/being written by nitpicking nerds. When we explain that w3fools is written by some of the biggest names in web development, you still insist it isn't valid. When we offer a legit alternative, you dismiss it by saying it's almost as unclear as the W3C site, which is patently ridiculous to anyone that's taken time to look at both of them. At the end of the day, your 'counter-argument' boils down to simply, "Nuh uh!" which is hardly compelling. You're entitled to your opinion. It's not shared by any respectable professional in this business, but you're entitled to it. That said, as a matter of course, we at PHP Freaks will never offer a link to w3schools as a solution to anything, and we will publicly criticize any post written by another that recommends it. Our purpose is to help people, and offering up incomplete or just plain wrong resources to people struggling to learn PHP and other web development skills is the opposite of helping.
  22. Why are you trying to create a new object in each iteration of the loop? And why are you overwriting that object in each iteration of the loop?
  23. Frank, w3schools is widely considered to be an incomplete, and at times utterly wrong, reference. We don't support it's use here simply because we believe that incorrect information hinders learning. The 'nerds' you so easily dismiss are some of the industry's best and brightest. Simply put, they have the cachet to determine whether or not a resource is good or if it's harmful. A far better resource to use is the Mozilla Developer Network (https://developer.mozilla.org/en-US/). You taking criticism of w3schools personally is, quite frankly, bizzare. Neither Christian, nor David, nor requinix were insulting in their criticism. If you are in any way connected to w3schools (which is the only logical reason I can think of for your reaction), I think you'd be smart to take the criticism to heart rather than simply lashing out.
  24. The most obvious thing to do would be to consolidate your load options code into a function of its own. Something like: function load_options() { $options = array(); $options['title'] = stripslashes(get_option('opening_times_widget_title')); $options['email'] = stripslashes(get_option('opening_times_widget_email')); $options['description'] = stripslashes(get_option('opening_times_widget_description')); // etc. return $options; } You can then invoke the function like: $options = load_options(); Once you have your $options variable, you can just access the options like: echo $options['title']; // where you can replace 'title' with whatever it is you want to use EDIT: For future reading: http://php.net/manual/en/language.functions.php http://php.net/manual/en/language.types.array.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.