Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. No, he's suggesting that you just take one from whatever number your using that relies on the index starting at one. A good suggestion.
  2. My apologies. I actually intended to quote the person above you(RussellReal). Obviously clicked the wrong button. I also didn't notice that you'd already mentioned most of what i'd said. One of those days, i guess.
  3. What collation is the field in the database and what charset does the page have?
  4. Are you aware of a.) how difficult it is to ascertain a user's true IP address and b.) that some people have IPs that will change with every single request whilst other people will have the same IP as an awful lot of others who use the same ISP?
  5. Try something like: $getName_sql = "SELECT username FROM users WHERE username LIKE '%$input%' OR names LIKE '%$input%'"; $getName = mysql_query($getName_sql); $aUsers = array(); while($row = mysql_fetch_assoc($getName)){ $aUsers = $row['username']; }
  6. Then you need to refer to Ken's question: The string shouldn't change unless you do anything to it. Incidentally, now would probably be a good time to point out that a user might modify that hidden field. Just because it's hidden, don't assume a malicious user wouldn't change it.
  7. Given that you can indeed use the return statement to return control back to the file that did the including, i would imagine this arises out of PHP's look-ahead ability. Unlike some languages, you need not declare a function prior to it's usage in your script - it can appear anywhere. So, whilst in other languages, the function definition would never be arrived at the second time that file is included, PHP has already "seen" the function before even considering the rest of the logic flow.
  8. Erm, why are you passing it in a hidden field at all? The date is almost certainly going to be the same when the form is loaded as when it is submitted, right?
  9. Seeing as we've moved on a bit, the change in question was: function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; echo 'Query was: '.$q.'<br />'; return mysql_query($q, $this->connection) or trigger_error(mysql_error(),E_USER_ERROR); } If you're saying you get no output from this function to the screen, then i can only assume it isn't being called anywhere. I can't see anywhere in the other code that you have posted where you actually call this function. Defining a function doesn't execute the code inside; you must call it with those parameters (username, field and value).
  10. Well assuming you do have error_reporting and display_errors on, that would suggest to me that the query either isn't ever being executed or there are no matching rows. Try echoing that query to make sure: function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; echo 'Query was: '.$q.'<br />'; return mysql_query($q, $this->connection) or trigger_error(mysql_error(),E_USER_ERROR); }
  11. This has nothing to do with the direction of the slashes. You have two problems. Your first is operator precedence. The !== operator has higher precedence than the = operator, so it is evaluated first. The result of readdir($dh) !== false is then assigned to $file. So because that is true for each iteration, 1 is assigned to $file. Your second problem is that you need to append the file name to the directory: <?php $dir = "C:\Program Files\VertrigoServ\www"; if(is_dir($dir)) { $dh = opendir($dir); while(($file = readdir($dh)) !== false) { echo "filename :" . $file . "filetype : " . filetype($dir.'\\'.$file); } }else { echo "can not find dir"; echo $dir; }
  12. Take a look at this FAQ/topic: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html
  13. The first step would be to add some debugging to the query: return mysql_query($q, $this->connection) or trigger_error(mysql_error(),E_USER_ERROR); Other than that, we'd need to see a bit more of your code. Where is the function called?
  14. Well, you never updated your code further down. Try replacing this section: if (empty($s)) {$s=0;} $query.=" limit $s,$limit"; With: $offset = ($page-1)* $limit; $query .= "LIMIT $offset,$limit";
  15. You've mixed your quote types in your query. Backticks can be used to demarcate fields and table names whilst standard quotes are used to delimit strings: $result = mysql_query("SELECT SUM(money) FROM `users`") or trigger_error(mysql_error(),E_USER_ERROR); $sum = mysql_result($result,0); echo "Sum of the rows is $sum";
  16. T'other way round. The regular sorting functions sort lowest to highest; the (k)rsort functions sort highest to lowest.
  17. You'll have to read the files into an array along with their modification times (obtained using filemtime) and sort on those times. I'd probably use the name as the index of the array and the modification time as the values so sorting is simply a case of a call to rsort
  18. Read is also a reserved word. Use backticks(`) around it or(better) rename your field. See here for a full list of reserved words.
  19. So store more values? $details['Tom'] = array('location'=>'london','age'=>22); $details['Dick'] = array('location'=>'timbuktu','age'=>25);
  20. do you get why? Frankly, i don't suppose someone who triple posts gives a damn why.
  21. You want to use the less than operator (<), not the less than or equal to operator (<=) in that for loop. Computers start counting at 0; while there are two elements in that array their indexes are 0 and 1 respectively. Edit: Beaten to it but posted for the explanation
  22. Would you care to show us the actual example then? It's a bit difficult to debug a syntax error without your actual code.
  23. As long as you use the equality operator(==) and not the identical operator(===) you don't need to worry about types. Two variables are considered equal (but not identical) regardless of their type.
×
×
  • 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.