Problems with wamp (mysql connection)
Posted by: Luca (46.11.77.---)
Date: November 29, 2012 07:53PM

$dbhost ="127.0.0.1";
$mysql_user="root";
$mysql_password="my password etc etc " (changed for security)
$dbname="login";

if ($username&&$password)
{
//connect to database
$connect = mysql_connect("dbhost", "mysql_user", "mysql_password" or die("Couldn't connect to database" ));


mysql_select_db("dbname" ) or die("Couldnt find database " );


....


Localhost/mysql password in cmd works (for root) /phpmyadmin (logs in and lets me create tables etc) are all working . But the problem is that when i try connecting i seem to get only this error.


) Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\test\Task 2 Coursework\Login.php on line 22
Call Stack
# Time Memory Function Location
1 0.0008 684792 {main}( ) ..\Login.php:0
2 0.0012 686800 mysql_connect ( ) ..\Login.php:22



If u think it might be a port problem, its not as the apache is set to .80 and sql normal on 3306 (edited)

How can i arrange this?



Edited 2 time(s). Last edit at 11/29/2012 08:22PM by Luca.

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: stevenmartin99 (Moderator)
Date: November 29, 2012 07:56PM

it is a port problem


sql is not normal on 3307

its 3306.

ifg you set it to 3307 then you have to write 127.0.0.1:3307


please dont try and answer your own questions, its one way that will stop most peope replying to you

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: Luca (46.11.77.---)
Date: November 29, 2012 08:19PM

ohh sorry wrote the wrong number confused smiley , its on 3306

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: stevenmartin99 (Moderator)
Date: November 29, 2012 08:28PM

please test using the testmysql.php in the www folder,

edit it and add your details,

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: Luca (46.11.77.---)
Date: November 29, 2012 08:46PM

Could not connect to MySQL: php_network_getaddresses: getaddrinfo failed: No such host is known.



Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\test\testmysql.php on line 8


$dbhost ="127.0.0.1";
$dbuser="root";



Edited 1 time(s). Last edit at 11/29/2012 08:46PM by Luca.

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: Luca (46.11.77.---)
Date: November 29, 2012 09:59PM

Can anyone please respond? i have wasted a whole week on trying to arrange this....

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: RiggsFolly (---.as13285.net)
Date: November 29, 2012 11:20PM

have you tried using localhost instead of 127.0.0.1

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: Luca (46.11.77.---)
Date: November 29, 2012 11:44PM

Yeah when i tried that, a different error occurs,

Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'mysql_user'@'localhost' (using password: YES) in C:\wamp\www\test\Task 2 Coursework\Login.php on line 22


But im sure i changed the pass from the user>privilages in phpmyadmin

Options: ReplyQuote
Re: Problems with wamp (mysql connection)
Posted by: RiggsFolly (---.as13285.net)
Date: November 30, 2012 10:37AM

Just spotted an error in the php code for the connect


//connect to database
$connect = mysql_connect("dbhost", "mysql_user", "mysql_password" or die("Couldn't connect to database" ));


Should be

//connect to database
$connect = mysql_connect("dbhost", "mysql_user", "mysql_password" ) or die("Couldn't connect to database" );


note the ending ')' for the mysql_connect is in the wrong place on your code

Options: ReplyQuote


Sorry, only registered users may post in this forum.