This question already has an answer here:
i am trying to do registration page so when the user fill the fields, the information should go to the database but it keeps showing me this:
Notice: Undefined variable: sql in C:\xampp\htdocs\Bawazir\Untitled-1.php on line 92
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
here is the code :
Notice: Undefined variable: sql in C:\xampp\htdocs\Bawazir\Untitled-1.php on line 92
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
</div>
"Notice: Undefined variable: sql ... "
means that you are trying to use a variable that doesn't exist or is not defined at that moment.
Try defining the $sql
variable at the beginning of the file where your database connection is.
Notice: Undefined variable: sql in C:\xampp\htdocs\Bawazir\Untitled-1.php on line 92
That code above means that you are trying to use a variable before it actually has a value in it. You need to make sure $sql has a value when it is being used.
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
That means that your used credentials are wrong and the connection to the database is refused. Make sure you use the right credentials that you have set in phpMyadmin.