Jump to content

rythemton

Members
  • Posts

    107
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

rythemton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I second ginerjm, if only one selection is allowed, you want a radio button or drop-down list. Also, you should use JavaScript for validation. Using PHP means that the person has to submit the form before they know that what they submit was invalid, unless you use Ajax (which uses JavaScript) which is going to require more work than just using JavaScript in the first place. Your PHP should also validate the information in case the user has JavaScript disabled, but you shouldn't make people wait to know they've input invalid information if at all possible. You don't need to use Java. Java is not JavaScript.
  2. If you are inserting into a date column, MySQL expects a YYYY-MM-DD format. For a datetime column, YYYY-MM-DD HH:MM:SS.
  3. For hashing, I've started using the php password script that's mentioned by trq. http://us2.php.net/password The biggest benifit is that the hash will update with the PHP versions. No reason to reinvent the wheel. if( password_verify( $password, $hashedpassword ) ) { // user logged in if( password_needs_rehash( $hashedpassword, PASSWORD_DEFAULT ) ) { $updatedhash = password_hash( $password, PASSWORD_DEFAULT ); // insert updated hash into database } } The only problem is that it wasn't introduced til PHP 5.5.
  4. This solution should work for what you want, because it rotates the links in the file itself, rather than keeping a counter.
  5. The problem is that you are using a COOKIE. Cookies are unique per computer and per browser, so when someone new gets on, or a new browser is used, their system has no 'link_index' cookie, and the count starts over. You need to save the 'link_index' on the server in some way that is not computer or browser specific. A Session won't work either, because it is also unique per computer and per browser, just stored on the server instead of the client machine.
  6. Let me verify a few things: $clones is an array, correct? $clones[2] is an object of some type, correct? Are $clones[0] and $clones[1] the same type of object? If $clones[0] and/or $clones[1] are not the same type of object as $clones[2] then trying to assign something to $clones[0 or 1]->attackGroup will throw an error and stop the script, and it will never get to $clones[2]. We difinetely need more information.
  7. There is something missing. Both cases should work. Are there any error messages? Does this code work? foreach($clones as $key => &$value) { $value->attackGroup = $_POST['type'][$key]; } Without seeing more code, it's nearly imposible to figure out what's wrong.
  8. The first error is caused because mysql_query() returns a FALSE if there is something wrong with the query. The second error is saying the the $CURUSER variable has not been set. Variable names are case sensitive. Also, check for mispellings. The next error can be resolved by checking to see if the $_GET and $_POST variables are set with isset() as suggested by PaulRyan. The last error, as PaulRyan states, is because the sqlerr() function doesn't exist. As with variable names, functions are case sensitive.
  9. To be honest, it's really hard to tell how the images are stored. They could be stored as files that are directly accessed, or they could be stored as files that are indirectly accessed through a script, or they could be stored in a database as a 'blob' (binary large object) and accessed through a script. Your browser can't tell the difference, so it's hard to tell what process was used. If you have done everything correctly, it shouldn't matter how you have stored the images. I usually store the files in a locked directory so that they can't be accessed directly, then I use a PHP script to fetch the files. The only thing I store in the database is details about the file (height, width, original file name, etc.) and I don't store the files by their original name, that way I can guarantee that each file is uniquely named and doesn't overwrite other files.
  10. No. I'm suggesting the following: $stmt = $database->stmt_init(); $query = "UPDATE table SET group = (?), username = (?)"; $types = 'is'; $query .= " WHERE userid = (?)"; $types .= 'i'; //Debugging echo 'Query: '.$query.'<br />'; echo 'Types: '.$types.'<br />'; echo 'Types - DATA TYPE: '.gettype($types).'<br />'; $stmt->prepare($query); $stmt->bind_param($types, $vbulletin->GPC['user']['usergroupid'], $vbulletin->GPC['user']['username'], $vbulletin->GPC['userid']); $stmt->execute(); $stmt->close(); $database->close(); And now that I've looked at the manual, I don't think mysqli will allow arrays in bind statements.
  11. World of Warcraft has an API that can be used to retrieve information from the WoW Armory: http://sourceforge.net/p/wowarmoryapi/home/Home/
  12. There is a difference between: "first text, second text" and: "first text", "second text" Your are using the first in your prepare statement, but PHP is expecting the second. Your other option is to use an array as ChristianF suggested.
  13. Your second bit of code doesn't work the way you think it does: if (substr($foobar, 0, 2) === 'ab' or 'ba') // This won't work right This is going to check if the first two characters is 'ab', then it's going to check to see if 'ba' is TRUE or FALSE, which will be always TRUE because a nonempty string is considered TRUE in PHP. So you can see this better, here is your code again using parenthesis to show order of precedence: if ( ( substr($foobar, 0, 2) === 'ab' ) or ( 'ba' ) ) You'll need to do the comparison twice for it to work right: if (substr($foobar, 0, 2) === 'ab' or substr($foobar, 0, 2) === 'ba') As for checking variation in Caps, there are many ways you could go. One of the easiest in this case would be to force the results to be lowercase: if (strtolower(substr($foobar, 0, 2)) === 'ab' or strtolower(substr($foobar, 0, 2)) === 'ba') You can see more of PHP order of precedence at http://php.net/manual/en/language.operators.precedence.php For more complicated checks, you can also use regular expressions, which can shorten your code.
  14. Putting the directory name as a variable should work, as long as the directory actually exists. If each user will have a different directory for their files, then you need to either create the directory when the username is created, or check to see if the directory exists when a file is uploaded, and create it if the directory does not exist. If the directory does exist but you still can't upload, then it may be a permissions issue.
  15. I agree with xyph, doing both functions in a single loop is more efficient and would the preferred method.
×
×
  • 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.