Jump to content

Error message & localhost


vickie

Recommended Posts

After using MAMP to update old code and testing, I uploaded all the changed pages to our server.  Now, the error message reads:

Error: Unable to connect to MySQL server: : '' :Access denied for user 'xxxx'@'localhost' (using password: YES)

 

I don't recall where I change the localhost to point to our server?  Anyone have a guess? 

 

Yes, I'm new to this and it's trial by fire right now. 

Link to comment
https://forums.phpfreaks.com/topic/201800-error-message-localhost/
Share on other sites

The username is correct.  How do I check for the database, dumb question...but I really don't know what to do next.  Could the code I changed the other day have an effect on the database? 

 

When I talked with the ISP, they said the localhost needed to read as the server.  Does that make sense?

 

BTW, Ken, I sent you an email message.

they said the localhost needed to read as the server

 

You need the correct hostname (something like myslx.your_web_host.com) or the IP address of the correct mysql server for your account.

 

You can usually find this somewhere under your hosting control panel where you created the database/user/password.

Here is the code:

<head>
<?php
require('admin2/admin2.php');
$sql=new MySQL_class;
$sql->Create("nae");
?>

HTML/CSS...

<!-- Member log in -->

<?php
if (isset($_POST['submit'])) {
$query="SELECT * from members WHERE id = $_GET[id]";
$data = $sql->Query($query);
if ($sql->rows>0 && $pass)
{if ($pass!=$repass)
{echo" Your password fields do not match, please <a href='javascript:history.back()'>click here</a> to go back.";}
else{$cpass=crypt($pass, substr($pass,0,2));

echo" Welcome aboard..please <a href='../membersmenu.phtml'>click here</a> to log into members area";
$email="website ";
$mailstuff="member $id has just became active";
mail($email, "A new member just signed up", $mailstuff, "From: autoresponder\n");}
}else{
echo" Either Your ID # does not exist in our database, or you did not fill out password fields,   <a href='javascript:history.back()'> click here to go back</a>. If the problem persists please email us at: info@website  ";	}
}else{?> 

<form action="membersmenu.phtml" method="post" >
<table width="100%" border="0" cellspacing="5" cellpadding="0"  >
                               
                                  
                                  <tr> 
                                    <td><h1 class="color_b">Members Log In</h1></td>
                                  </tr>
                                  <tr> 
                                    <td class="style46">Member ID <input name="id" type="text" class="input" size="10" maxlength="20" /></td>
                                  </tr>
                                  <tr> 
                                    <td><span class="style46">Password  </span> <input name="pass" type="password" size="10" maxlength="20"  class="input" /></td>

                                  </tr>
                                  <tr> 
                                    <td class=""><input type="submit" name="submit" value="Sign in" class="button" style="background-color: #f5deb3" /> <a href="http://www.website/members/id_pass_change.phtml" class="style46"><span style="font-size: 80%;">forgot password?</span></a></td>
                                  </tr>
  </table>                                
  </form>

</div>
<!-- End log in -->

HTML/CSS...

<div id="footer">
<?php
@readfile('http://www.website/ssi/ssi-footer.html');
?>
</div>
<? } ?>

</div></div></div>
</body>
</html>

And there is this file, if it will provide any clues...??

<?
/*
* Utility routines for MySQL.
*/

class MySQL_class {
    var $db, $id, $result, $rows, $data, $a_rows;
    var $user, $pass, $host;

    /* Make sure you change the USERNAME and PASSWORD to your name and
     * password for the DB
     */

    function Setup ($user, $pass) {
        $this->user = $user;
        $this->pass = $pass;
    }

    function Create ($db) {
        if (!$this->user) {
            $this->user = "user";
        }
        if (!$this->pass) {
            $this->pass = "pass";
        }
        $this->db = $db;
        $this->id = @mysql_connect($this->host, $this->user, $this->pass) or
            MySQL_ErrorMsg("Unable to connect to MySQL server: $this->host : '$SERVER_NAME'");
        $this->selectdb($db);
    }

    function SelectDB ($db) {
        @mysql_select_db($db, $this->id) or
            MySQL_ErrorMsg ("Unable to select database: $db");
    }

    # Use this function is the query will return multiple rows.  Use the Fetch
    # routine to loop through those rows.
    function Query ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
    }

    # Use this function if the query will only return a
    # single data element.
    function QueryItem ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
        $this->data = @mysql_fetch_array($this->result) or
            MySQL_ErrorMsg ("Unable to fetch data from query: $query");
        return($this->data[0]);
    }

    # This function is useful if the query will only return a
    # single row.
    function QueryRow ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
        $this->data = @mysql_fetch_array($this->result) or
            MySQL_ErrorMsg ("Unable to fetch data from query: $query");
        return($this->data);
    }

    function Fetch ($row) {
        @mysql_data_seek($this->result, $row) or
            MySQL_ErrorMsg ("Unable to seek data row: $row");
        $this->data = @mysql_fetch_array($this->result) or
            MySQL_ErrorMsg ("Unable to fetch row: $row");
    }

    function Insert ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform insert: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }

    function Update ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform update: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }

    function Delete ($query) {
        $this->result = @mysql_query($query, $this->id) or
            MySQL_ErrorMsg ("Unable to perform Delete: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }
}

/* ********************************************************************
* MySQL_ErrorMsg
*
* Print out an MySQL error message
*
*/

function MySQL_ErrorMsg ($msg) {
    # Close out a bunch of HTML constructs which might prevent
    # the HTML page from displaying the error text.
    echo("</ul></dl></ol>\n");
    echo("</table></script>\n");

    # Display the error message
    $text  = "<font color=\"#ff0000\" size=+2><p>Error: $msg :";
    $text .= mysql_error();
    $text .= "</font>\n";
    die($text);
}
?>

Thanks roopurt18 for the warning, I will check into that.

 

This is the "current and working page" that I've been updating to new code due to a server move which resulted in the page I posted earlier.  So where is the problem, there wasn't a whole lot changed....

<head>
<?php
require('admin2/admin2.php');
$sql=new MySQL_class;
$sql->Create("nae");
?>

<!-- Member log in -->
<?if ($submit)
{$query="select * from members where ID='$id'";
$data = $sql->Query($query);
if ($sql->rows>0 && $pass)
{if ($pass!=$repass)
{echo" Your password fields do not match, please <a href='javascript:history.back()'>click here</a> to go back.";}
else{$cpass=crypt($pass, substr($pass,0,2));

echo" Welcome aboard..please <a href='../membersmenu.phtml'>click here</a> to log into members area";
$email="info@website ";
$mailstuff="member $id has just became active";
mail($email, "A new member just signed up", $mailstuff, "From: autoresponder\n");}
}else{
echo" Either Your ID # does not exist in our database, or you did not fill out password fields,   <a href='javascript:history.back()'> click here to go back</a>. If the problem persists please email us at: info@website  ";	}
}else{?> 

<form action="membersmenu.phtml" method="post" >
<table width="100%" border="0" cellspacing="5" cellpadding="0"  >
                               
                                  
                                  <tr> 
                                    <td><h1 class="color_b">Members Log In</h1></td>
                                  </tr>
                                  <tr> 
                                    <td class="style46">Member ID <input name="id" type="text" class="input" size="10" maxlength="20" /></td>
                                  </tr>
                                  <tr> 
                                    <td><span class="style46">Password  </span> <input name="pass" type="password" size="10" maxlength="20"  class="input" /></td>

                                  </tr>
                                  <tr> 
                                    <td class=""><input type="submit" name="submit" value="Sign in" class="button" style="background-color: #f5deb3" /> <a href="http://website/members/id_pass_change.phtml" class="style46"><span style="font-size: 80%;">forgot password?</span></a></td>
                                  </tr>
  </table>                                
  </form>
</div>

<div id="footer">
<?php
@readfile('http://www.website/ssi/ssi-footer.html');
?>
</div>
<? } ?>

</div></div></div>
</body>
</html>

Archived

This topic is now archived and is 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.