Jump to content

MySQL Error


tsilenzio

Recommended Posts

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? =/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.