Andy1 Posted October 17, 2010 Share Posted October 17, 2010 Hey guys, I need some help really badly! I'm a total n00b when it comes to this mySQL and php thing, and I need to connect to my mySQL database using a php script. I've used about 30 different scripts and received 2 errors that I can't seem to fix. I'm using mySQL 5.0.22, with phpMyAdmin 2.11.10 All i want is to connect to the database using a php script. My access is denied, which I don't uderstand because I know all that information is correct. And the error message states that there's a problem with line 7, which i'm pretty sure is the database handle line. $username = "Blackrose"; $password = "password"; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; This code lands me with the error Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'Blackrose'@'localhost' (using password: YES) in C:\Inetpub\vhosts\blackroseeroticliterature.com\httpdocs\config.php on line 7 Unable to connect to MySQL PLEASE HELP ME!!!!! All I want is to connect to the database so that I can get on with the rest of the code.. Thanks in advance to anyone who can help! Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/ Share on other sites More sharing options...
ignace Posted October 17, 2010 Share Posted October 17, 2010 The error message is self explanatory the log-in details are wrong! Show us a screen of you being logged into PHPMyAdmin this will give us more information to what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1122950 Share on other sites More sharing options...
Andy1 Posted October 18, 2010 Author Share Posted October 18, 2010 I've attached a screenshot of my phpmyadmin thing. all signed in and everything. I really hope someone can help, i've been stuck on this for 3 days. Cheers [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123157 Share on other sites More sharing options...
Pikachu2000 Posted October 18, 2010 Share Posted October 18, 2010 Did you check the hosting company's FAQ/other documentation to make sure your script should use localhost for the MySQL server's hostname? Often it gets specified by the IP address or actual hostname such as sql1.hostingco.com. That would be where I'd start if I were you. Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123216 Share on other sites More sharing options...
Andy1 Posted October 18, 2010 Author Share Posted October 18, 2010 I actually stumbled across the hostname by accident. according to other forums, if it says "localhost" in the top left on myadminphp or whatever then that's the hostname. but that turned out wrong. Thank You so much for helping me!!!!! but I have another issue now (not so pressing as the last though) my registration page is showing some of the script on the actual page. it's an error message function i think. but i don't want this to be visible to page visitors. 0 ) { echo ' '; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo ' •',$msg,' '; } echo ' '; unset($_SESSION['ERRMSG_ARR']); } ?> is the part that shows through on the actual page. i'm pretty sure that bullet point isn't meant to be there. but I'm not sure if that's the problem or if something else is missing. the full script is: 0 ) { echo ' <UL class=err>'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo ' <LI>',$msg,'</LI>'; } echo '</UL>'; unset($_SESSION['ERRMSG_ARR']); } ?> <FORM id=loginForm method=post name=loginForm action=register-exec.php> <TABLE border=0 cellSpacing=0 cellPadding=2 width=300 align=center> <TBODY> <TR> <TH>First Name </TH> <TD><INPUT id=fname class=textfield name=fname></TD></TR> <TR> <TH>Last Name </TH> <TD><INPUT id=lname class=textfield name=lname></TD></TR> <TR> <TH width=124>Login</TH> <TD width=168><INPUT id=login class=textfield name=login></TD></TR> <TR> <TH>Password</TH> <TD><INPUT id=password class=textfield type=password name=password></TD></TR> <TR> <TH>Confirm Password </TH> <TD><INPUT id=cpassword class=textfield type=password name=cpassword></TD></TR> <TR> <TD> </TD> <TD><INPUT value=Register type=submit name=Submit></ although all the TR's and TD's don't show up in any of my other scripts so yeah. not sure what that's about! the page just looks ugly with all that extra text on the page, i've seen it on sites before and it makes me shudder. but i don't want to attempt to change anything and risk the whole lot. it stills works it just doesn't TELL you if there's an error, and it looks ugly. So if you could help me out with this last thing (hopefully) i'd be VERY appreciative! Thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123252 Share on other sites More sharing options...
Pikachu2000 Posted October 18, 2010 Share Posted October 18, 2010 You've left a quote open, or a tag unclosed, or something like that. Can you post the script within . . . tags? Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123255 Share on other sites More sharing options...
Andy1 Posted October 18, 2010 Author Share Posted October 18, 2010 This is the original code. I haven't added or deleted anything from it, and it comes up with that ugly scrawl on the screen. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Login Form</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <?php if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) { echo '<ul class="err">'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo '<li>',$msg,'</li>'; } echo '</ul>'; unset($_SESSION['ERRMSG_ARR']); } ?> <form id="loginForm" name="loginForm" method="post" action="register-exec.php"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <th>First Name </th> <td><input name="fname" type="text" class="textfield" id="fname" /></td> </tr> <tr> <th>Last Name </th> <td><input name="lname" type="text" class="textfield" id="lname" /></td> </tr> <tr> <th width="124">Login</th> <td width="168"><input name="login" type="text" class="textfield" id="login" /></td> </tr> <tr> <th>Password</th> <td><input name="password" type="password" class="textfield" id="password" /></td> </tr> <tr> <th>Confirm Password </th> <td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Register" /></td> </tr> </table> </form> </body> </html> Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123263 Share on other sites More sharing options...
Pikachu2000 Posted October 18, 2010 Share Posted October 18, 2010 I see the problem. Rename the file with a .php extension and try it again . . . Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123412 Share on other sites More sharing options...
Andy1 Posted October 19, 2010 Author Share Posted October 19, 2010 It does the same thing, just on a white background. It's just irritating. I'd just prefer it to not be there. Quote Link to comment https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.