Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/216074-please-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123216
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123252
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/216074-please-help/#findComment-1123263
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.