Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:28:49+00:00 2026-06-14T10:28:49+00:00

Possible Duplicate: PHP/MySQL – SQL syntax error? I am trying to update a user

  • 0

Possible Duplicate:
PHP/MySQL – SQL syntax error?

I am trying to update a user password with the below script, however I am just getting the following error. I have been using PHP and MySQL for only about 2 months now so am still a beginner so I would really appreciate any comments regarding my below code. Thank you in advance for your help.

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 ‘(password, salt) VALUES (
‘fcf829e6c3478752799b7d49798a14640f110dd4f8767’ at line 1

<?php

//Pull in form info

$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];

//Chrck if the 2 password fields match
if($pass1 != $pass2) {
    header('Location: ../admin/pass-change.php?pw=notmatched');
    die();
}

//encrypts the password

$hash = hash('sha256', $pass1);

//creates a 3 character sequence

function createSalt()
{
    $string = md5(uniqid(rand(), true));
    return substr($string, 0, 3);
}
$salt = createSalt();
$hash = hash('sha256', $salt . $hash);

//initialise connection with databse

require_once('../Connections/EliteGrooming.php');

mysql_select_db($database_EliteGrooming, $EliteGrooming);

//Execute the query

$username = $_SESSION['username'];

$query = "UPDATE admin_users (password, salt)
        VALUES ( '$hash', '$salt' )
        WHERE username = '$username';";
mysql_query($query) or die(mysql_error());;
mysql_close();
header('Location: ../admin/pass-change.php?PassChanged');

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:28:51+00:00Added an answer on June 14, 2026 at 10:28 am

    no, it should be

    UPDATE admin_users 
       SET password = '$hash', 
            salt = '$salt' 
    WHERE username = '$username'
    

    beware, your query is vulnerable with SQL Injection, please the article below

    • How can I prevent SQL injection in PHP?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php/Mysql query with inserting date fails I have a datepicker code below:
Possible Duplicate: PHP - MySQL access denied error - Works in other programs i'm
Possible Duplicate: php sample script for pagination Suppose after a Process, My MySQL Table
Possible Duplicate: How to properly escape a string via PHP and mysql I'm trying
Possible Duplicate: PHP & MySQL Pagination Update Help So, in my site, there are
Possible Duplicate: How I can create installer for website. PHP mysql I'm looking to
Possible Duplicate: Rating System in PHP and MySQL I am working on a rating
Possible Duplicate: Close mysql connection (PHP) Please help me, I not know where add
Possible Duplicate: Format mysql datetime with php Well.. I have stored date(c) in Mysql
Possible Duplicate: Best practice: Import mySQL file in PHP; split queries How to import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.