Greenie Posted November 28, 2006 Share Posted November 28, 2006 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 MachineDatabase usage: Non-Transactional Database OnlyConcurrent Connections to server: Decision Support (DSS)/OLAPEnabled TCP/IP Networking (Port Number 3306)Enabled Strict ModeInstalled As a Windows ServiceRoot password as blankI'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 More sharing options...
Greenie Posted November 28, 2006 Author Share Posted November 28, 2006 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 More sharing options...
Recommended Posts