tsilenzio Posted July 11, 2007 Share Posted July 11, 2007 Okay i have this annoying problem everytime i try to test out to see if registration works on my test server: Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\dbz\includes\functions.php on line 72 Access denied for user 'ODBC'@'localhost' (using password: NO) (There is no password its just root and noo password) do i HAVE to have a password is it telling me? =/ Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 11, 2007 Share Posted July 11, 2007 It looks like it's connecting as "ODBC", not "root". Are you defining the user as root? (The "using password: NO" is just FYI to help you figure out what's wrong.) Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 11, 2007 Author Share Posted July 11, 2007 if i do need one anyone know how to add it? Im using WAMP which auto install and sets up Apache2, PHP 5, and MySQL5 on windows =/ been trying to figure it out accidently deleted the root account before lol had to reinstall Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 11, 2007 Author Share Posted July 11, 2007 This is my config file (file it loads to connect to DB) <?php $db_hostname = "localhost"; $db_username = "root"; $db_password = ''; $db_database = "database"; ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 This is my config file (file it loads to connect to DB) <?php $db_hostname = "localhost"; $db_username = "root"; $db_password = ''; $db_database = "database"; ?> For some reason mysql_connect doesn't like that root stuff without a password. I would edit mysql via command line and create a user. Google MySQL Create User to find out how to do that and give him access to the database. Quote Link to comment Share on other sites More sharing options...
nloding Posted July 11, 2007 Share Posted July 11, 2007 When WAMP is running, there should be an icon in the system tray ... right-click and you should be able to access phpMyAdmin ... and create a user very easily from there. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 11, 2007 Share Posted July 11, 2007 Try this:Do not Use double quotes, and include this file in any page you want. <?php $dbhost= localhost; $dbuser= root; $dbname= database; $connect=mysql_connect($dbhost,$dbuser)or die(mysql_error()); $mysqldb=mysql_select_db($dbname); ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 Try this:Do not Use double quotes, and include this file in any page you want. <?php $dbhost= localhost; $dbuser= root; $dbname= database; $connect=mysql_connect($dbhost,$dbuser)or die(mysql_error()); $mysqldb=mysql_select_db($dbname); ?> Come on now, let's not teach bad coding practice. You always put quotes around variable definitions for literal values. If you don't it takes it as a constant which causes a notice error which slows down processing time. The quotes around the variable definitions have nothing to do with it. <?php $dbhost= "localhost"; $dbuser= "root"; $dbname= "database"; $connect=mysql_connect($dbhost,$dbuser)or die(mysql_error()); $mysqldb=mysql_select_db($dbname); ?> Let's not try and teach him an inefficient way of coding, and on that note if for some reason his username was ROOT and he had a constant defined as ROOT, well the ROOT constant definition would be assigned to $dbuser. Create a user for the MySQL database and don't use the root with blank password. You should have a user for each database anyway for security purposes. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 11, 2007 Share Posted July 11, 2007 Try this:Do not Use double quotes, and include this file in any page you want. <?php $dbhost= localhost; $dbuser= root; $dbname= database; $connect=mysql_connect($dbhost,$dbuser)or die(mysql_error()); $mysqldb=mysql_select_db($dbname); ?> Come on now, let's not teach bad coding practice. You always put quotes around variable definitions for literal values. If you don't it takes it as a constant which causes a notice error which slows down processing time. The quotes around the variable definitions have nothing to do with it. <?php $dbhost= "localhost"; $dbuser= "root"; $dbname= "database"; $connect=mysql_connect($dbhost,$dbuser)or die(mysql_error()); $mysqldb=mysql_select_db($dbname); ?> Let's not try and teach him an inefficient way of coding, and on that note if for some reason his username was ROOT and he had a constant defined as ROOT, well the ROOT constant definition would be assigned to $dbuser. Create a user for the MySQL database and don't use the root with blank password. You should have a user for each database anyway for security purposes. I have used this method for years and never came by one little tiny error regarding Mysql connection. Although you make a good point for the timing, and security issue. I would go with what you said... Quote Link to comment Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 I have used this method for years and never came by one little tiny error regarding Mysql connection. Although you make a good point for the timing, and security issue. I would go with what you said... I never said you would have a MySQL error, rather PHP Notice Errors. turn error_reporting to E_ALL www.php.net/error_reporting See how many notice errors you can come up with on each of your pages. Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 11, 2007 Author Share Posted July 11, 2007 ok well since u guys are here lol any adive on this: would do u perfer to use and why (USALLY): " or ' when it coems to strings as far as i know with the echo statment u can use "$username is cool" would actally replace $username with username but that dosnt work with ' (single quotes) however hwne u go to write in html its better to use ' (in my opinion) becasue when u have to do something like <?php //more html code above echo('<body bgcolor="#ffc11c">'); //more html code ?> is better then using: <?php //more html code above echo("<body bgcolor=\"#ffc11c\">"); //more html code ?> Like i said i dont know and i wanna keep in good pratice Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 12, 2007 Share Posted July 12, 2007 If I don't need variable interpolation, I'll use single quotes as the parser doesn't need to scan the string for variables, and I don't need to escape as much. I'll use double quotes when I need to interpolate a variable, which I usually prefer to concatenation for readability. For example, "see $a variable" is easier to read than 'see ' . $a . ' variable', especially in longer strings. In your two examples, you're right that the first is the better since you don't have any variables and you won't need to escape the doubles if you enclose the string in single quotes. So, single quotes when you can for performance/efficiency reasons, but it's not really that big of a deal, so feel free to use double quotes as freely as you need for variable interpolation. IMHO. Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 12, 2007 Author Share Posted July 12, 2007 okay i figured out my problem it when u dont specify a username and all that stuff well i had it in a file and then another using require_once so it wasnt loading it up twice thus causing the vars to not have any values Quote Link to comment 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.