Randy Posted May 26, 2006 Share Posted May 26, 2006 [code]<?php // ---------- $host = "localhost"; $user = "electri_ryan"; $pass = "*********"; // ---------- mysql_connect($host, $user, $pass) or die("Error Connecting: ".mysql_error()); $dbs = mysql_list_dbs(); if(mysql_num_rows($dbs) > 0){ while(list($db) = mysql_fetch_row($dbs)){ if($db == "forums"){ $exists = true; } } } if(!$exists){ echo("Database does not exist!"); // Create database... mysql_query("CREATE DATABASE `forums`"); }?>[/code]Ok, when i run this code, no errors, and it echoes out "Database does not exist!", but when i look in cPanel, there is not a database calles forums...Anybody know what is wrong? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/ Share on other sites More sharing options...
Randy Posted May 26, 2006 Author Share Posted May 26, 2006 Ok, i made a very simple test...[code]<?php mysql_connect("localhost","electri_ryan","*********"); mysql_query("CREATE DATABASE `forums`") or die(mysql_error());?>[/code]When i run this i get the error:Access denied for user: 'electri_ryan@localhost' to database 'forums'Do i have to set privileges or something? 'electri_ryan' has all privileges... Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39269 Share on other sites More sharing options...
DoggerWatson Posted May 26, 2006 Share Posted May 26, 2006 [!--quoteo(post=377386:date=May 26 2006, 02:44 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 26 2006, 02:44 PM) [snapback]377386[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ok, i made a very simple test...[code]<?php mysql_connect("localhost","electri_ryan","*********"); mysql_query("CREATE DATABASE `forums`") or die(mysql_error());?>[/code]When i run this i get the error:Access denied for user: 'electri_ryan@localhost' to database 'forums'Do i have to set privileges or something? 'electri_ryan' has all privileges...[/quote]from 1 Noob to another Noob, if all you want to do is create a db; why not use the PHPMyAdmin from your CPanel. No point doing things the hard way. Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39333 Share on other sites More sharing options...
Randy Posted May 27, 2006 Author Share Posted May 27, 2006 NO, i do not want to create a database using cPanel, i was making a forum that is dynamic and can be put on a website easily. Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39414 Share on other sites More sharing options...
DapperDanMan Posted May 27, 2006 Share Posted May 27, 2006 [!--quoteo(post=377386:date=May 26 2006, 02:44 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 26 2006, 02:44 PM) [snapback]377386[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ok, i made a very simple test...[code]<?php mysql_connect("localhost","electri_ryan","*********"); mysql_query("CREATE DATABASE `forums`") or die(mysql_error());?>[/code]When i run this i get the error:Access denied for user: 'electri_ryan@localhost' to database 'forums'Do i have to set privileges or something? 'electri_ryan' has all privileges...[/quote]I have noticed that some ISPs do not allow you to create databases this way. I am only taking a shot in the dark, but can you create a new database from phpMyAdmin? My current ISP does not allow me to do this (I'm sure it has something to do with a server configuration/setup that is beyond me). I can only create new databases within cPanel. Hopefully that explains your mystery, if not, I would love to hear the outcome. Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39438 Share on other sites More sharing options...
avo Posted May 27, 2006 Share Posted May 27, 2006 HiIs apache setup correct on you pc ?Have you got a full white dial ?can you connect and loginto phpmyadmin manualy?let me know your results.first these will need to be working as i noticed you are connecting to a localhost if you are connecting to a external server then this will need to be address with the correct connection data not localhost.hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39476 Share on other sites More sharing options...
Randy Posted May 27, 2006 Author Share Posted May 27, 2006 I am running this script on my server, not on my computeri use localhost all the time for select, update, insert and such and it always works... Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39482 Share on other sites More sharing options...
avo Posted May 27, 2006 Share Posted May 27, 2006 [!--quoteo(post=377602:date=May 27 2006, 05:14 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 27 2006, 05:14 PM) [snapback]377602[/snapback][/div][div class=\'quotemain\'][!--quotec--]I am running this script on my server, not on my computeri use localhost all the time for select, update, insert and such and it always works...[/quote]HI If this is your server and on the same internet connection you would use something like 192.168.1.101 or localhost (no firewall or routed )(in your house)for example if your server is running from somewhere else in the world (one you are paying for)you would use there connection address.wwwservername.co.ukwhich one is it ?cheers. Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39485 Share on other sites More sharing options...
Randy Posted May 27, 2006 Author Share Posted May 27, 2006 [!--quoteo(post=377605:date=May 27 2006, 05:21 PM:name=avo)--][div class=\'quotetop\']QUOTE(avo @ May 27 2006, 05:21 PM) [snapback]377605[/snapback][/div][div class=\'quotemain\'][!--quotec--]HI If this is your server and on the same internet connection you would use something like 192.168.1.101 or localhost (no firewall or routed )(in your house)for example if your server is running from somewhere else in the world (one you are paying for)you would use there connection address.wwwservername.co.ukwhich one is it ?cheers.[/quote]the www.electric-monkey.com/ type Quote Link to comment https://forums.phpfreaks.com/topic/10506-create-database/#findComment-39516 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.