php - Can't connect to database to update member details -
i can't connect database while running page on submitting updated details. life of me can't figure out why wont connect.
most recent error:
warning: mysql_connect() [function.mysql-connect]: access denied user 'matts1'@'localhost' (using password: yes) in f:\xampp\htdocs\site\profileupdate.php on line 69 cannot connect
below db.inc file details well, since has no password have no clue why error being posted.
my db.inc file is:
$hostname = "localhost"; $username = "root"; $password = ""; $databasename= "schurter_products";
php/sql:
<?php session_start(); require 'db.inc'; // initialise error string $errorstring = ""; // trim posted values - gets rid of unecessary whitespace $firstname = trim($_post["firstname"]); $surname = trim($_post["surname"]); $emailaddress = trim($_post["emailaddress"]); $username = trim($_post["username"]); $password = trim($_post["password"]); //here use validation @ server // vaildate firstname if (empty($firstname)) // first name cannot null string $errorstring .= "\n<br>the first name field cannot blank."; // validate surname if (empty($surname)) // user's surname cannot null string $errorstring .= "\n<br>the surname field cannot blank."; // validate email address if (empty($emailaddress)) // user's address cannot null string $errorstring .= "\n<br>you must supply @ least 1 address line."; // validate username if (empty($username)) // user's city cannot null string $errorstring .= "\n<br>you must supply city."; // validate password if (empty($password)) // user's city cannot null string $errorstring .= "\n<br>you must supply state."; // script has finished validation, // check if there errors if (!empty($errorstring)) { // there errors. show them , exit. ?> <!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/tr/html4/loose.dtd" > <html> <head><title>customer details error</title></head> <body bgcolor="white"> <h1>customer details error</h1> <?=$errorstring?> <br><a href="updateinsertform.php">return customer form</a> </body> </html> <?php } else { // if made here, data valid mysql_connect("$hostname", "$username", "$password")or die("cannot connect"); mysql_select_db("$databasename")or die("cannot select db"); // update $query = "update members set firstname = '$firstname', surname = '$surname', emailadress = '$emailaddress', username = '$username', password = '$password' id = '$memberid'"; $recordset = mysql_query($query) or die ("error in query: $query. ".mysql_error()); echo "your updates complete!"; } ?>
haha sorry, see problem. overwrite username :)
$username = "root";
and
$username = trim($_post["username"]);
hence error user:
access denied user 'matts1'@'localhost'
rather user "root".
Comments
Post a Comment