Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. Since the very first line of your counter.php file is a die statement, I have to assume you don't mean for it to ever be viewed or included by another script. You could try and do something with regexps or complicated text parsing to remove the PHP from the file, but why bother? Just take the PHP out of the file and place it in a non-web accessible directory. You aren't planning to include() it and it won't be accessible via the browser. Alternatively you could give the file a non PHP extension, something like .nv (no-view) and set up an .htaccess rule to not allow any files ending with that extension. I have to wonder why you're not using a DB to store this information as well. You're making a mountain out of a mole-hill IMO.
  2. You use count() to count the number of elements in an array. The problem you are facing likely deals with the way different OSes deal with newlines. *nix : \n Windows : \r\n (or \n\r, I forget the exact order) Mac : \r mgall hinted at this earlier but didn't explain in any detail. If you want to explode on the newline character in a file created by any OS: <?php $contents = file_get_contents("the/file"); $contents = str_replace("\r", "\n", $contents); $contents = str_replace("\n\n", "\n", $contents); $lines = explode("\n", $contents); echo count($lines); ?> You could do it even more simply: <?php $lines = file("the/file"); echo count($lines); ?>
  3. FF / Netscape / Opera use the DOM L2 event model. Are you passing an event object to your event handler?
  4. I think it's supposed to be: window.location.href = <rvalue>;
  5. <script type="text/javascript"> function disp_confirm(){ var name=confirm("You're going to delete this item, would you like to process it?") if (name==true){ window.location("delete.php?id=$data[id_cat];") }else{ return true; // change true to false if it doesn't work } } </script>
  6. I prefer to use htmlentities over strip_tags simply because it makes it easier to spot attacks; it also clearly shows to the attacker (assuming they can view what they've submitted) that you protecting against it. Hopefully that would limit their inclination to try and attack more forms in your site.
  7. Just a suggestion, but echoing only one of potentially multiple errors and forcing your users to click to go back is an interface nightmare. It's cumbersome and likely to frustrate people. Why not set your form up so that if there are errors it automatically re-displays the form, resets all of the fields to what the user initially chose, and displays all of the error messages on the top?
  8. If you want to cancel the default event you need to return either true or false from the event handler. I forget which value (true, false) is used to cancel the default action associated with the onclick event. Just try one and then the other.
  9. Do a google search for "wiki cron" and cron jobs in general. If using a Windows server you'd be using scheduled tasks.
  10. It's already assigned to a variable; when the form is submitted it will be in the variable $_POST["selection"]. What is the next step you're trying to accomplish?
  11. AND LENGTH(paypal) > 0 By the way, strings in SQL are written with single quotes, not double, unless I'm mistaken.
  12. I'm not sure if you meant this when you said you would use a CASE, but you could LEFT JOIN each of the possible tables and return the one where `name` IS NOT NULL. Could be performance issues with that though.
  13. Oh yes, right. Right. I may have been under the influence when I posted that!
  14. Do what? Here's a query that will do this for you: SELECT username, COUNT( DISTINCT username ) * someNumber AS `occurs` FROM your_table GROUP BY username ORDER BY username
  15. The PHP script would echo something like this: { option : [ { value : "valueString", display : "displayString" }, { value : "valueString1", display : "displayString1" }, { value : "valueString2", display : "displayString2" } ] } And your JS would do something like: var obj = exec(xhr.responseText); Read up on JSON to get a better handle for it.
  16. They might have technical reasons for not using OOP, such as a large number of sites that would break if the upgraded their server(s). It really doesn't matter if you're programming in OOP or using procedural methods. You can still learn and use OOP for your personal interest / projects and I highly recommend doing so. In fact I recommend you take time to learn more languages than just PHP; I'd start by learning a little more about MySQL or Javascript as they're very relevant to PHP. The major downfall to procedural coding is it lends itself to a populated global namespace, many constants, and a bit of code repetition. Neither style is more effective in terms of execution, although slight variances in execution time will occur.
  17. You should avoid using innerHTML wherever possible IMO. I like to return my AJAX requests as JSON. In this case I'd have returned an object a single property named options. options would be an array of objects with the properties value and display. It would look something like this: // Inside the AJAX handler var sel = document.getElementById("theSel"); var JSON = responseToJSON(xhr.responseText); if(JSON != null && typeof JSON.options == "array"){ var max = JSON.options.length; for(var i = 0; i < max; i++){ var opt = JSON.options[i]; var optEl = document.createElement("option"); optEl.value = opt.value; optEl.appendChild(document.createTextNode(opt.display)); sel.appendChild(optEl); } }
  18. What about entertainment value? /popcorn
  19. All of them are best at what they do and anyone who says a particular OS sucks is looking at too broad a scope in terms of functionality IMO. The best way to look at this is with an analogy. Let's pretend that Linux, MacOS, and Windows are all VCRs. The Linux VCR would have all sorts of buttons and functionality built into it. You'd be able to set it up to do complicated things. The Windows VCR would have the basic functionality. Probably start, stop, rewind, and fast forward buttons. Maybe one or two extra features tucked away, but that's it. The Mac VCR wouldn't have any buttons at all. You'd just insert your tape and it'd automatically play with no way of stopping, fast forwarding, etc. until the tape hit the end and automatically ejected for you. In this case, the Linux VCR would be great for movie fanatics. The Windows VCR would be suitable to the broader market of movie watchers. The Mac VCR would be great for your grandparents. All three VCRs accomplish the same task to the satisfaction of their target audience; thus all three are the best. The same principles apply to every argument about which XYZ is best; best is only ever determined by the audience, which makes this entire post a long winded way of saying it's all a matter of opinion. Azu, I don't know anything about you, but since you are so set on Windows sucking, I'd like to present you with a little challenge. Find a non-computer savvy individual over 40 and give them a Linux box that is already set up and installed. Next, walk them through downloading and installing a piece of software over the phone; then give that same person a desktop with Windows and an MS Office CD and walk them through installing that over the phone. Finally, come back and tell us which is "best."
  20. roopurt18

    Geese

    I think this is pretty far off the mark. A person's gender is often times the same as their sex, but not always. In terms of society and social interaction, it is often times a person's gender that is the more important of the two. I think it is for this reason that the term gender is used more often. To be clear on the matter, sex refers to your sexual organs like Jesirose stated. Gender refers to which sex a person identifies with.
  21. I'm not really sure how else you'd go about doing it. meetings id | datetime | name | description | notes SELECT datetime, name, description FROM meetings ORDER BY datetime DESC LIMIT 1 Then you just give them an admin page to add, edit, and delete entries. A general page to view all meetings that have occurred along with their notes would be helpful. I'm not really sure what you were looking for as an answer.
  22. I'm confused. You said you have a large system that builds these arrays with data from the database. You then say that new entries would be added to the database and you're not sure how to insert this data into the array. Are you saying that this array is pre-built somewhere else? Another way of phrasing that question would be are you not querying directly from the DB each time you access this data? If the answer is yes then I have to wonder if there's not a more efficient way of querying the database for the data you need. How about providing a (small) example of what this array ultimately looks like using print_r() as well as your table structure. Then we can maybe help you query for the data directly in the format you want it.
  23. Here is my version, which is recursive for arrays and has a few other options: <?php // my_clean // $data - data to clean before inserting into db // $add_sq - true to add single quotes, false to just clean // $force_string - true to treat the data as a string // $skip_strip - true to skip the strip slashes segment // RETURN: properly escaped and db safe data function my_clean($data, $add_sq = true, $force_string = false, $skip_strip = false){ if(is_array($data)){ foreach($data as $key => $val){ $data[$key] = $this->my_clean($val, $add_sq, $force_string); } }else{ $data = trim($data); if(!is_numeric($data) || $force_string){ if(get_magic_quotes_gpc() && !$skip_strip){ $data = stripslashes($data); } if($add_sq){ $data = "'" . mysql_real_escape_string($data) . "'"; }else{ $data = mysql_real_escape_string($data); } } } return $data; } ?>
  24. No problem. I learned something myself in the process.
×
×
  • 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.