Novice,
This is rather complicated code. In addition you are making it over complicated by taking constants and just renaming them as other contants. This accomplished nothing. You would be better of just placing the information in the correct place. Otherwise you can make the arguments into variable such as:


$usr = 'masud';

Then,

mysqli_connect ($host, $usr, $pwd, $db)

In this case you could have a form which would allow users to access their own database and projects.
You do not need that if the statement unless you need an error or die message. (Which is standard and a good idea).
Google has alot of these answers
jzf


Novice Learner wrote:

Make sure that:

localhost is actually "localhost"
username is the actual authorized username of the database
the password is the actual password you have given for the user
the database is the actual database name you have given.

I am an absolute beginner and I have a file like this and works perfectly, 
although I had a lot of problems in the beginning, I use the following code:

// Set the database access information as constants.
define ('DB_USER', 'masud');    //This is the actual user name
define ('DB_PASSWORD', 'mylove'); //This is the password
define ('DB_HOST', 'localhost'); //This is the localhost
define ('DB_NAME', 'masud'); //This is the actual database name
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the 
connnection.

Just my two cents.


Denis Gerasimov <[EMAIL PROTECTED]> wrote:

Hello,

I am trying to connect to MySQL using

$mysqli = new mysqli("example.com", "user", "pass", "db");

And access is ALWAYS denied
(I played around changing user name/pass/host - didn't help me at all)

The thing is that I CAN connect to the db server using this user name and
password with my DB administration tool.

Some background
1. MySQL and Apache + PHP are running on the same machine.
2. The user is allowed to connect from '%' (everywhere)
3. Connecting to localhost fails too (saying "cannot connect to socket...")

What is going on?

Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru




-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to