Jump to content

Cant connect to MySQL database


Greenie

Recommended Posts

Hello all,

I'm very new to both PHP and MySQL and I'm following the [url=http://www.w3schools.com/php/php_mysql_intro.asp]w3schools.com's tutorials[/url]. I've set up an Apache server correctly (as far as I can tell) and I'm trying to use the following script to connect to my MySQL database:

[code]
<html>
<body>
<?php
$con = mysql_connect();

if($con) { echo "connection successful"; } else { echo "connection attempt failed"; }
?>

</body>
</html>
[/code]

And when I open the php file the failed attempt string appears.

I'm not really sure how I'm supposed to set up MySQL. I have the following settings:
Server Type: Developer Machine
Database usage: Non-Transactional Database Only
Concurrent Connections to server: Decision Support (DSS)/OLAP
Enabled TCP/IP Networking (Port Number 3306)
Enabled Strict Mode
Installed As a Windows Service
Root password as blank

I've enabled Port 3306 on my firewall program. Still it doesn't work.

Can anyone suggest where I might be going wrong here? I'd be happy to provide any information you may need to answer my question.
Link to comment
Share on other sites

I managed to get this script to work and to connect to my MySQL database. Boy, did it take some effort!

I had to re-install MySQL, making sure I assigned a password this time. I then had declare some additional parameters to the mysql_connect() command, using the syntax:

[code]
mysql_connect(servername,username,password);[/code]

It took me ages to figure out that the default username is "root".

No further assistance required.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.