www.webdeveloper.com
Results 1 to 3 of 3

Thread: Access denied

  1. #1
    Join Date
    Apr 2013
    Posts
    61

    Access denied

    I have a couple of docs with the following warning. thanks for help.
    Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in
    C:\xampp\htdocs\folder\file.php on line 17
    Unable to select database:
    HTML Code:
    <HTML><body bgcolor="ccffff"><center>
    <form name="taxset" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post">
    Select state/rate <p><SELECT name="taxrate">
    <OPTION value=0.04000 selected>4% Alabama
    <OPTION value=0.05600 >5.6% Arkansas
    </Select>
    <p><CENTER><INPUT type=image height=24 alt="submit button" width=129 src="rollsubmit.gif" 
        border=0>
    </FORM>
    PHP Code:
    <?php
    if(isset($_POST['submit']))
    {
    $taxrate $_POST['taxrate'];
    }
    // error_reporting(0);
    error_reporting(E_ALL E_NOTICE);
    mysql_connect("localhost","root"," ");
    mysql_select_db("numbersdb") or die( "Unable to select database");
    if(!empty(
    $_POST["submit"]))
        {
    $id $_POST['id'];
     
    $query="SELECT * FROM numbdata";
    // Where taxrate='$taxrate'
     
    $result=mysql_query($query);
     if(
    $result)
        {
       }  
     else{echo 
    "invalid entry, $taxrate.<br /> select another?<br />";
        }
       }
    if(!empty(
    $_POST["update"]))
        {
    $sql "UPDATE numbdata SET
     taxrate = '" 
    mysql_real_escape_string($_POST['taxrate']) . "'
      WHERE id ='"
    .$_POST["id"]."'";
     
    mysql_query($sql) or die("Update query failed.");
     echo 
    "taxrate has been set ...";
    }
     
    ?>
    HTML Code:
    <form name="settax" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
     <br />
     <input type="text" name="taxrate"/> <p>
    <INPUT type=image height=24 alt="submit button" width=129 src="rollsubmit.gif border=0>
    </CENTER></form></body></html>

  2. #2
    Join Date
    Mar 2011
    Posts
    1,136
    The password you're using in the call to mysql_connect() is wrong. If there's no password on your 'root' account, use "" instead of " ".
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Apr 2013
    Posts
    61
    of course, thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles