connect failed (1045)1045
Posted by: nitewalk (156.98.48.---)
Date: September 28, 2006 01:17PM

Hi,
I'm using wamp5 ver. 1.6.4 e seems that work fine when I write only php script.
now, I completed my first database and when I run php script I receive the error connect failed (1045)1045. reading other emails i find out that this happen to often.
i understood that there is a file called config.php, but i can't find it. Instead I find config.inc but do not look like the one describe in the email from "Serving the King' . I checked in the phpmyadm, php, and mysql the file is not there.
I create a new one but I don't know where to put it. Please is sombody that can help me.
Thank you.

Options: ReplyQuote
http://forum.wampserver.com/read.php?f=2&i=681Re: connect failed (1045)1045
Posted by: CyberSpatium (---.hsd1.or.comcast.net)
Date: September 28, 2006 04:23PM

wamp comes with the default mysql root use set with no password, so to connect to your database with your php scripts, use

mysql_connect( 'localhost', 'root', '' );

I highly recomend for security concerns you add a password for you root user. there are also a few more stepsyou should take to further secure your wamp server. check the second post here:

[forum.wampserver.com]

Options: ReplyQuote
Re: http://forum.wampserver.com/read.php?f=2&i=681Re: connect failed (1045)1045
Posted by: nitewalk (156.98.48.---)
Date: October 03, 2006 10:00AM

thanks CyberSpatium, I have done everything explained by other fellow but nothing work right. I had to uninstall and install several tme wamp5 to make it work again.
I'm learning php and mysql using the book "Core web development" by Marc Wandschneider' . He use this script in the book to make connection to the datebase:

<?php
$conn = @new mysqli('localhost', 'user' , 'password', 'database');
if (mysql_connect_errno() !=0)
{
$errno = mysqli_connect_errno();
$errmsg = mysqli_connect_error();
echo "Connect Failed with: ($errno) $errmsg<br/>\n";
exit;
}
....................................
.....................................
$conn->close();
?>
Do you have any other suggestion for me.
Thank for you time.

Options: ReplyQuote
Re: connect failed (1045)1045
Posted by: CyberSpatium (---.hsd1.or.comcast.net)
Date: October 03, 2006 08:28PM

make sure you have started both apache and mysql. also since you are

also, you php code is not valid, change it to this:

<?php
$conn = @new mysqli('localhost', 'user' , 'password');
$conn->select_db( 'database');
if (mysqli_connect_errno() !=0)
{
$errno = mysqli_connect_errno();
$errmsg = mysqli_connect_error();
echo "Connect Failed with: ($errno) $errmsg<br/>\n";
exit;
}

Options: ReplyQuote
Re: connect failed (1045)1045
Posted by: nitewalk (---.hsd1.mi.comcast.net)
Date: October 07, 2006 05:08AM

Ok, I figure out the problem. The solution was in the database privilege. in fact I was givng wrong privileges to the user. Thank you CyberSpatium for your time, ad thanks for the connections code they works fine in the same way my code too.
Thank you,
nitewalk.

Options: ReplyQuote


Sorry, only registered users may post in this forum.