-2

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)

2 Answers2

0

"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.

jeromej
  • 10,508
  • 2
  • 43
  • 62
Xcytek
  • 1
  • 1
  • 1
0

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.

Cameron
  • 1,049
  • 12
  • 24
hcoder
  • 103
  • 11