DavidAM
Staff Alumni-
Posts
1,984 -
Joined
-
Days Won
10
Everything posted by DavidAM
-
See the sticky: HEADER ERRORS - READ HERE BEFORE POSTING THEM Post your code from the start of the file AND PUT IT IN CODE TAGS Post the ENTIRE error message so we know where to start looking. This statement Sessionn_start(); is completely invalid. It should not start with a capital letter, and it should not have two "n's" in it. If this is the way it is written in your source file, you need to 1) Fix it! and 2) Turn On Error Reporting so you see these errors and can fix them. By the way, Session_destroy(); should not be capitalized, either.
-
Preserving values in input field after page gets refreshed
DavidAM replied to eldan88's topic in PHP Coding Help
Can I ask Why you want to do this? I really hate that Firefox refuses to clear out my fields when I refresh a page. If I refresh a page, I expect a pristine new copy of the page, that's why I hit REFRESH. When I am testing a form and having trouble with some JS / AJAX / PHP, and I make some code changes and hit REFRESH, it doesn't clear out the form and I have to find some other way to force it to reload the page. I guess, I expect a refresh to be a reload. Am I the only one who thinks like this? -
If I understand your code, you are depending on mySql to NOT update the row if all of the provided values are the same values that are already in the table. But mySql is saying it updated the row. Is that correct? 1) Is there an UPDATE TRIGGER on this table that sets some other field (like LastModifieDate) when a row is updated? 2) Is there a TIMESTAMP column that is automatically set to the current time when a row is updated? 3) Did you TRIM your input strings before the original INSERT? and are you TRIMing your input strings before this UPDATE? On second thought ... Your Menu Positioning Code is setting the cat_position to NULL for the edit_cat_id. So the cat_position column is going to be updated in the UPDATE query you are talking about in your original post.
-
Page can only be seen by members with a certain rank
DavidAM replied to Bubblychaz's topic in PHP Coding Help
And do NOT EVER store the user's password in a cookie!!! There is NO reason to keep the user's password floating around in a Cookie or a Session, EVER. -
How many seconds in a week depends entirely on what week you are talking about. There are two weeks in each year that will have 1 hour more or less than the usual -- the weeks when Daylight Saving Time changes. The best approach for your situation is to use strtotime : $start = strtotime("+1 week", $start); instead of adding some number of seconds.
-
I don't think that the sql is valid. You should test the result of the mysql_query call to see if it fails and print the mysql error (at least in development): // You do NOT need the FROM clause in this simple UPDATE, and the table comes BEFORE the SET clause $sql = "UPDATE users SET last_date='$last_date' WHERE id='$userid'"; if ( ! mysql_query($sql)) { print('Query Failed: ' . $sql . "<BR>\n" . mysql_error()); } Or something along those lines.
-
Oops! I thought that dot was a comma. You are right.
-
That should do it. But what is that VINEGAR there? The fourth parameter is a boolean indicating whether you want raw (binary) output or not. Unless VINEGAR is a constant with a value of FALSE, you are getting raw data back, which would be 1/2 the length of the printable value.
-
This topic has been moved to CSS Help. http://forums.phpfreaks.com/index.php?topic=361877.0
-
The size of the hash returned by hash_hmac() is controlled by the chosen algorithm, in this case SHA 512. So, you would have to look up that algorithm to get the answer (I don't know what it is). I think what Pikachu was saying is to run strlen() against the result and it will tell you the size. For any given algorithm (md5, sha1, etc.) the result will always be the same length for that algorithm, regardless of the input string (or file).
-
radio button option posted to a backend php program
DavidAM replied to helen11's topic in PHP Coding Help
Your radio buttons are in a separate FORM element. When you submit a form, only the elements in the FORM that contains the submit button are submitted. -
For the record, mySql allows an alternate syntax for INSERT that uses the SET phrase. So, the original code is valid for an insert. The provided code does NOT increment the post_no. The code INSERTs a record, period. If you want to increment a column in an existing row, you have to use UPDATE. It looks like you want to check to see if the user has an entry. If found, then UPDATE it (incrementing the post_no). If no row is found, then do an INSERT with post_no set to 1.
-
Can't get mod_rewrite to work Friendly URL to Access Web Page
DavidAM replied to TecTao's topic in Apache HTTP Server
That has to do with the flags you have on the rewrite rule. The "R" tells Apache to redirect to the url that you have built. Take the "R" out and it should work as you expect. Also, there is no reason to capture those values separately, you can use a single capture group RewriteRule ^([A-Za-z][A-Za-z][0-9]+)$ /webpage.php?rep_id=$1 [NC,L] -
I would just json_decode it as an array instead of as objects. Then you can reference them as array keys: $data_stats = json_decode($ret, true); $projected_points = $data_stats['body']['player_stats'][$id]['FPTS'];
-
Hm, I'm surprised it works. I did not think that methods or properties could start with a digit. However, to use a variable in that expression, you would put it in curly braces: $projected_points = $data_stats->body->player_stats->{$id}->FPTS I've used it with property names and method calls, but never in the middle of a chain like that, so YMMV. Oh, and NO, this is not what is meant by "extending a class" (unless I am really out of the loop here).
-
Can't get mod_rewrite to work Friendly URL to Access Web Page
DavidAM replied to TecTao's topic in Apache HTTP Server
Your rewrite rule is looking for one or more uppercase letters followed by a dash followed by one or more digits. Your description of the problem and your example do not indicate there should be a dash there. Your rewrite rule is also supplying a dash in the GET variable; again, not mentioned in the problem statement. From the description of the problem and the example, I would use: RewriteRule ^([A-Z]{2,2}[0-9]+)$ webpage.php?rep_id=$1 [L] Also, I just noticed, you are capturing the domain name so IT would be $1, the letters would be $2 and the digits would be $3. Oh yeah, and you don't get the domain name for the rewrite rule, you only get the page (and directories) -
While some good suggestions have been provided - particularly the array_filter() and min() functions, the problem with that code was pointed out by xyph in the first response. This statement: if ($laagsteBbreukX[$y] != 'error' && $laagsteGet = 'error'){ is assigning "error" to $laagsteGet instead of testing, and results in a True condition, so the if is always true (except for the last entry in the sample array). The code should probably be: if ($laagsteBbreukX[$y] != 'error' && $laagsteGet == 'error'){ Notice the second "=" in the last comparison.
-
Certain characters have special meaning in the URL, so the browser must encode them before sending them. PHP realizes this, and will (should) decode them before you see them in $_GET. Are you seeing a problem processing this data in your PHP script? If so, describe the problem you are having and we can probably help. Are you just looking for a way to make the url look "pretty"? If so, you need to look into the (Apache) mod_rewrite module.
-
You are replacing the value in $options each time through the loop. You need to append them: $options = array(); // Initialize the result array foreach($query->result() as $rows) { /* This would give you an array of arrays ... $options[] = array($rows->id => $rows->cat_name); */ // But I suspect what you really want is a single-dimension keyed by ID $options[$rows->id] = $rows->cat_name; }
-
need help with printing <a href> links with vars
DavidAM replied to Aston's topic in PHP Coding Help
If $link[1] does not exist. Then explode did not find a comma in the string. You might add a check after the explode: if (count($link) < 2) { trigger_error('invalid line in link file: ' . $activelink, E_USER_WARNING); } that should show you the bad line so you can go fix it in the text file. -
The problem is that ENUMs in MySQL are inherently strings. Consider the following example: CREATE TABLE Things ( ThingID INT UNSIGNED AUTO_INCREMENT, Category ENUM ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'J') ); CREATE TABLE Categories ( CatID INT UNSIGNED AUTO_INCREMENT CatName VARCHAR(50) ); Now, when you select from the Things table, you will see the Category column as those letters. However, if you use the Category column in an integer expression, you will get the integer value of the ENUM. So, SELECT ThingID, Category FROM Things -- Might Return ThingID Category 21 A 22 B 23 C 24 D 25 E 26 F 27 G 28 J -- However SELECT ThingID, Category + 0 AS Cat FROM Things -- Would Return ThingID Cat 21 1 22 2 23 3 24 4 25 5 26 6 27 7 28 8 Now, applying that to your situation. When you JOIN the tbl_fighter.Category to tbl_fighter_category.id the server has to use the integer value of the enum since the category table's ID is an integer. So your (string value of) "10" is actually ENUM value (integer) 8 and does not match the (integer) value 10 in the category table. Note that the server is NOT converting the enum string value (in your case "10") to an integer (which would be ... uhh ... 10). It IS using the ENUMERATED value, which in this case is 8. This is very confusing, and is the best reason NOT to use numbers for ENUM values. If you MUST stick with the design, use the next logical digit in the sequence (i.e. '8') instead of '10' -- or add the empty inactive categories of '8' and '9'.
-
Your "$filetype and $showname" stuff should be inside the loop, too. Basically, inside the loop, you process ONE file, as if it were a single-file upload --- well, the FILES array is slightly different.
-
I'm not sure what you mean by "every 1st". If you want special processing the VERY first time through the loop you would simply test for equality: if ($count == 1) { // First time through // do something important } elseif ( ($count % 4) == 0) { // Every 4th time // do something interesting }
-
This $datasetenum = array(); foreach( $dataset as $key => $val ){ $datasetenum[$val] = $key; } can be written in one line with array_flip as: $datasetenum = array_flip($dataset);
-
Usually means that that user does not have a login for the database server; OR The password provided is not the correct password for that user. I have never seen this message before. However, about 6 lines down you have: header("Content-type: text/xml"); You can NOT send a header after sending ANY content to the browser. The header would have to be sent BEFORE even the DOCTYPE is sent. I don't have any experience serving XML pages, but it would seem to me that your DOCTYPE, your <HTML> tag and this header all contradict each other. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> header("Content-type: text/xml");