Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Yeah, that's really the question here. You need to figure out which areas of PHP (or programming in general) you are weak in, and then research those specific topics.
  2. Well, I would recommend putting the code you already have into a function. That way all you have to do is call it from the select event. Alternatively, you could probably just bind the select.change event to the thumbnail.click event.
  3. It means the query failed due to an error. Try outputting the query to make sure it is what you expect, and use mysql_error to figure out what the error is.
  4. Where are you declaring the font-size?
  5. I think he was talking to Techrits...
  6. I made this quick JSFiddle (http://jsfiddle.net/vrUdd/) which (I think) does what you wanted. Hope that helps.
  7. You'd probably have to parse it with regular expressions. Or, depending on the structure, you might be able to use something like strtok. Or a combination of the two.
  8. This topic has been moved to CSS Help. http://forums.phpfreaks.com/index.php?topic=363527.0
  9. Of course they do. IE barely accepts valid markup. And even if it did work, it is an unnecessary, hacky solution. Just because it might "work" doesn't mean you should do it. That is a very bad philosophy to have as a programmer.
  10. 1. Use proper brackets. if($count>0) { echo "username exists"; } else { echo "not exists"; } 2. Don't use $_REQUEST 3. Sanitize input before using it with a database if(isset($_POST['dun'])) { $dun = mysql_real_escape_string($_POST['dun']); $sel=mysql_query("select username from reg where username='$dun'"); Your problem is the fact that you are terminating the script if there are no rows returned, on this line: $count=mysql_num_rows($sel) or die(mysql_error()); If mysql_num_rows() returns 0, the script is terminated and, since there is no MySQL error, you get no output. So, change it to $count=mysql_num_rows($sel);
  11. Escape it when it goes to the database. If you are displaying it back to the user, it doesn't need to be escaped. You still need to be running htmlentities() or htmlspecialchars() for displaying though, to prevent XSS attacks.
  12. Can you post your new code?
  13. It does, but it's not used for displaying back to the user.
  14. URL's do not use back slashes.
  15. You get the same result either way, but the benefit is less code. For example to write data to a file you don't have to call fopen(), fwrite(), and fclose() - you simply call file_put_contents(). It's just a bit easier, is all.
  16. You don't need any of your code, just the one line I wrote. I mean, either way works fine, but file_get_contents() and file_put_contents() is the preferred method.
  17. Sure that will work, but you can simplify it a bit using file_get_contents and file_put_contents. <?php file_put_contents('hitcount.txt', ((int) file_get_contents('hitcount.txt')) + 1);
  18. Yeah, I understand. Just know that you will probably see the same problem to some degree no matter where you work. You will most likely have to succumb to the standards and practices set in place by the company. They may not be the best way to do it, but it's their way to do it and you just have to deal with it.
  19. Sessions are unique to the user, so they would only ever see their page views, but nobody else's. So, you would need to save the page views to a database, or a flat file or something.
  20. Something like this: // this variable would come from the result set of a query // but the value is set for the sake of brevity $r_status = 3; ..... <div id="profile_info_item"> <label> <select name="r_status" id="r_status"> <option value="1"<?php echo $r_status == 1 ? ' selected="selected"' : ''; ?>>Single</option> <option value="2"<?php echo $r_status == 2 ? ' selected="selected"' : ''; ?>>Married</option> <option value="3"<?php echo $r_status == 3 ? ' selected="selected"' : ''; ?>>Seperated</option> <option value="4"<?php echo $r_status == 4 ? ' selected="selected"' : ''; ?>>Divorced</option> <option value="5"<?php echo $r_status == 5 ? ' selected="selected"' : ''; ?>>Widowed</option> <option value="6"<?php echo $r_status == 6 ? ' selected="selected"' : ''; ?>>Tell You Later</option> </select> </label> </div> If you put your options in an array you can reduce the amount of code duplication, but this will work fine too. Also, you are using the same ID for multiple elements. ID's are supposed to be unique; you can only use them on one element. You need to use classes instead, which can be used on multiple elements.
  21. I would change the checkbox to this: <input type="checkbox" name="EmpFeedback[<?php echo $rowEmp['empno']; ?>]" value="1" /> Now, the array indexes will be the employee ID. When you process it, you will have to loop through the selected checkboxes and then do whatever. Something like this: if (isset($_POST['EmpFeedback']) && !empty($_POST['EmpFeedback'])) { $selectedEmps = $_POST['EmpFeedback']; foreach(array_keys($selectedEmps) as $emp) { // ... } } In the foreach loop, $emp will be an employee ID.
  22. With that method, you will have to run a query for every iteration of the result loop, which is never a good idea. Take a look at these two articles: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ http://www.sitepoint.com/hierarchical-data-database/
  23. The problem is, in these type of situations, you find yourself standing alone as all other dev's happily program against php3 Well, I guess you just need to suck it up then. Sure, it sucks being forced to write bad code or work in a inefficient environment. There is a part of you that simply isn't satisfied delivering nothing but the best, but you can only do so much with what you are given. As long as your boss thinks you are an asset and are productive, that's all that matters in the end.
  24. But seriously, PHP dev's are master trolls.
  25. So I just tested it, and I can't get line breaks to output with either function. I am guessing they are saved in the database as "\\r\\n", which means you probably have magic quotes on.
×
×
  • 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.