Results 1 to 2 of 2

Thread: warning in mysql_real_escape_string

  1. #1
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default warning in mysql_real_escape_string

    Good day!

    I am new in template in php like calling the .html webpage in php and I encountered warning in mysql_real_escape_string

    here is my code:
    PHP Code:
    <?php
    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    session_start();

      if (isset(
    $_SESSION['logged_in'])) {
         
    header('Location:machine1.php');
         die();
      }


     if (isset(
    $_POST['submit'])) {
        
    $username=$_POST['username']; 
        
    $password=$_POST['password'];


        
    $username mysql_real_escape_string($username);
        
    $password mysql_real_escape_string(sha1($password));
        
        
    //$username = $_DB->getEscaped($username);
        //$password = $_DB->getEscaped(sha1($password));


        //mysql_query("UPDATE machine_problem_rhoda_user SET password = '$password' WHERE username = '$username'");
        
        
    $sql_update "UPDATE machine_problem_rhoda_user SET 
                        password = '
    $password', 
                   WHERE username = '
    $username'";
        
        
    $sql_select "SELECT
                        username,
                        password
                   FROM
                        machine_problem_rhoda_user
                   WHERE
                           username='
    $username'
                        AND
                        password='
    $password'
                        "
    ;
                        
        
    $result $_DB->opendb($sql_select);

        
    $result=mysql_query($sql_select);
        
        
    $count=mysql_num_rows($result);

        if(
    $count==1){  
            
    $_SESSION['logged_in'] = true;
            
    header("location:machine1.php");
        }
        else {
        echo 
    "<center>";
        echo 
    "Wrong Username or Password";
        echo 
    "</center>";
        }
    }

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/index.html'));
    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');
    ?>
    And I got this warning:

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /opt/zeva/releases/ZEVA.sandbox/machine_problem/rhoda/index.php on line 20

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /opt/zeva/releases/ZEVA.sandbox/machine_problem/rhoda/index.php on line 20

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /opt/zeva/releases/ZEVA.sandbox/machine_problem/rhoda/index.php on line 21

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /opt/zeva/releases/ZEVA.sandbox/machine_problem/rhoda/index.php on line 21

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Are other mysql functions working? are you sure you have an open database connection, with the proper credentials? here, php is saying that it can't connect to your database.

Bookmarks

Posting Permissions

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