jimmyt1988 Posted June 22, 2010 Share Posted June 22, 2010 mysql_connect("serverlocation", "username", "password") or die(mysql_error()); mysql_select_db("databasename") or die(mysql_error()); foreach ($myArray as $output){ $sql="INSERT INTO maleNames (Name) VALUES('$output') "; or die(mysql_error()); $i++; } echo $i; echo "Data Inserted!"; mysql_close($con); It comes up with error: Error: No database selected Any ideas? Obviously the connecting credentials are replaced with username, password etc rather than the real. Quote Link to comment https://forums.phpfreaks.com/topic/205594-i-cant-connect-to-mysql/ Share on other sites More sharing options...
jimmyt1988 Posted June 22, 2010 Author Share Posted June 22, 2010 I named the file sql.php It stopped it working. Quote Link to comment https://forums.phpfreaks.com/topic/205594-i-cant-connect-to-mysql/#findComment-1075839 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.