Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Troy297's Avatar
    Join Date
    Oct 2006
    Location
    Earth
    Posts
    314
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question PHP/MySQL Inserting Data

    Hey All,

    I posted about this before but when I finally tried it I got some weird errors because I was using my own custom encryption function. So basically I have a table with un-encrypted passwords, and I want to turn them all into encrypted ones. So I use this sql:

    PHP Code:
    UPDATE TABLE rp_users SET passwrd enc(`passwrd`) 
    And I get this error.... and just so you know the "enc" function is a php function that is included in the page that just uses a series of complicated encryption strings on the password.

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`passwrd`)' at line 1
    And when I changed my SQL to this:

    PHP Code:
    UPDATE rp_users SET passwrd 'enc(`passwrd`)' 
    I don't get any errors, but instead of using the encryption function of the "password" of the table row it just inserts "enc(`passwrd`)" as the users new password. And I have also tried making the encryption part a variable and using the variable in the actual SQL String but when I do that it just encrypts "passwrd" instead of the actual password from the database.

    Any help would be really great! Thanks so much!
    Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
    Radio DJ Panel v3 - It's Here!

  • #2
    Regular Coder Troy297's Avatar
    Join Date
    Oct 2006
    Location
    Earth
    Posts
    314
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Nevermind... finally got it to work... for anyone who wants to know the code is below:

    PHP Code:
    $result mysql_query("SELECT passwrd FROM users");
    $row mysql_fetch_array($result);
    $cpass $row['passwrd'];
    $encpass enc($cpass);
    $queryf "UPDATE users SET passwrd = '$encpass'";
    $result mysql_query($queryf) or die(mysql_error()); 
    Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
    Radio DJ Panel v3 - It's Here!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •