GingerRobot
Staff Alumni-
Posts
4,082 -
Joined
-
Last visited
Everything posted by GingerRobot
-
[SOLVED] explode string, but array start at 1 ?
GingerRobot replied to asmith's topic in PHP Coding Help
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. -
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.
-
What collation is the field in the database and what charset does the page have?
-
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?
-
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.
-
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.
-
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?
-
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).
-
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); }
-
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; }
-
[SOLVED] Help with displaying result from mysql fetch
GingerRobot replied to Cappen's topic in PHP Coding Help
Take a look at this FAQ/topic: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html -
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?
-
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";
-
[SOLVED] Totaling "sum" of a field
GingerRobot replied to PJ droopy pants's topic in PHP Coding Help
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"; -
T'other way round. The regular sorting functions sort lowest to highest; the (k)rsort functions sort highest to lowest.
-
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
-
Read is also a reserved word. Use backticks(`) around it or(better) rename your field. See here for a full list of reserved words.
-
So store more values? $details['Tom'] = array('location'=>'london','age'=>22); $details['Dick'] = array('location'=>'timbuktu','age'=>25);
-
[SOLVED] why i can not see textbox what can i do?
GingerRobot replied to bakigkgz's topic in PHP Coding Help
do you get why? Frankly, i don't suppose someone who triple posts gives a damn why. -
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
-
Would you care to show us the actual example then? It's a bit difficult to debug a syntax error without your actual code.
-
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.
-
-
substr_count would do it.