I am importing a CSV file into my administration area and I want to add files to my database. My PHP code for import.php :
<?php include_once('../include/connection.php'); if ($_FILES[csv][size] > 0) { <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Import a CSV File with PHP & MySQL</title> </head> <body> <?php if (!empty($_GET[success])) { echo "<b>Your file has been imported.</b><br><br>"; } <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html>
The code displays correctly, but when I select my test file and click submit, I have the following problems:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in admin/import.php on line 23 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in admin/import.php on line 23 Warning: Cannot modify header information - headers already sent by (output started at admin/import.php:1) in admin/import.php on line 29
Can anyone see the reason?
my connection.php code is:
<?php try { $pdo = new PDO('mysql:host=localhost;dbname=*********', '*********', '*********'); }catch (PDOException $e){ exit('Database Error.'); } ?>
note that my other pages, like add.php, delete.php, edit.php etc., work with the same include_once for connection.php
SO DO NOT WATCH ANYTHING WITH MY DATABASE CONNECTION.
Thank you.
source share