Ruud Hermans Posted July 1, 2009 Share Posted July 1, 2009 I got the following files that give me an error when I go to signup.php config.php <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'busu'; ?> closedb.php <?php mysql_close($conn); ?> opendb.php <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> insert.php <?php include 'config.php'; include 'opendb.php'; $sql="INSERT INTO members (name, password, email, location) VALUES ('$_POST[name]','$_POST[password]','$_POST[email]', '$_POST[location]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; include 'closedb.php'; ?> signup.php <html> <body> <form action="insert.php" method="post"> Name: <input type="text" name="name" /> Password: <input type="text" name="password" /> Email: <input type="text" name="email" /> Location: <input type="text" name="location" /> <input type="submit" /> </form> </body> </html> Running signup.php leads to the following error when submitting the form: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Error connecting to mysql Opening files seperate leads to these errors: opendb.php Notice: Undefined variable: dbhost in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Notice: Undefined variable: dbuser in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Notice: Undefined variable: dbpass in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Error connecting to mysql insert.php Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2 Error connecting to mysql closedb.php Notice: Undefined variable: conn in D:\Test Server\EasyPHP 3.0\www\closedb.php on line 2 Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in D:\Test Server\EasyPHP 3.0\www\closedb.php on line 2 config.php gives no errors at all. Does someone have a clue what could be wrong here? Link to comment https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 1, 2009 Share Posted July 1, 2009 Anyone see what is wrong here?Partly, you keep posting mysql questions in the Microsoft SQL - MSSQL forum section. So, moving this one as well to the Mysql Help section... Link to comment https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/#findComment-867345 Share on other sites More sharing options...
fenway Posted July 2, 2009 Share Posted July 2, 2009 Your php mysql config section is wrong -- you shouldn't be logging in as root with no password. Link to comment https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/#findComment-867497 Share on other sites More sharing options...
febrarian Posted July 2, 2009 Share Posted July 2, 2009 Try not to include the closedb.php, try typing only mysql_close($conn); instead of <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> then run signup.php. Running your closedb.php and opendb.php would definitely ahve an error because you would need your config.php with that. Link to comment https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/#findComment-867522 Share on other sites More sharing options...
febrarian Posted July 2, 2009 Share Posted July 2, 2009 I just want to correct this.. instead of <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> to instead of include('closedb.php'); sorry! Link to comment https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/#findComment-867629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.