Hi All,
I am stuck at the very first part of my site, and have no idea why I and getting the below error message. I have tried recreating the user in the mysql database with the correct username and password, and even granted full access.
I am setting up a site and jsut created an initial default account to test everything is working fine, so din't mind sharing usernames and passwords if need be as I am currently setting up the webserver on a local machine just to test before launching it.
Username: test
Password: W@t3r
Table: test
Database: maindb
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'test'@'localhost' (using password: YES) in C:\xampp\htdocs\the_lab\labupload.php on line 8
MySQL connection failed: Access denied for user 'test'@'localhost' (using password: YES)
Here the initial part of my code, I am using it to upload files into my database:
<?php // Check if a file has been uploaded if(isset($_FILES['uploaded_file'])) { // Make sure the file was sent without errors if($_FILES['uploaded_file']['error'] == 0) { // Connect to the database $dbLink = mysqli_connect("localhost","test","W@t3r","maindb"); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Gather all required data $name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']); $mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']); $data = $dbLink->real_escape_string(file_get_contents($_FILES ['uploaded_file']['tmp_name'])); $size = intval($_FILES['uploaded_file']['size']); // Create the SQL query $query = " INSERT INTO `test` ( `name`, `mime`, `size`, `data`, `created` ) VALUES ( '{$name}', '{$mime}', {$size}, '{$data}', NOW() )"; // Execute the query $result = $dbLink->query($query); // Check if it was successfull if($result) { echo 'Success! Your file was successfully added!'; } else { echo 'Error! Failed to insert the file' . "<pre>{$dbLink->error}</pre>"; } } else { echo 'An error accured while the file was being uploaded. ' . 'Error code: '. intval($_FILES['uploaded_file']['error']); } // Close the mysql connection $dbLink->close(); } else { echo 'Error! A file was not sent!'; } // Echo a link back to the main page echo '<p>Click <a href="the_lab.html">here</a> to go back</p>'; ?>
I am using Apache, and Windows 7.