Dont know whats wrong with this (real_escape)

Discussion in 'PHP' started by killaklown, Aug 29, 2006.

  1. #1
    This is my login code:

    
    <?php
    if ($_POST['accountemail']) {
    //did they supply a password and username
    $email=mysql_real_escape_string($_POST['accountemail']);
    $password=mysql_real_escape_string($_POST['accountpassword']);
    if ($password==NULL) {
    echo "A password was not supplied";
    }else{
    $query = mysql_query("SELECT email,password FROM accounts WHERE email='$email'") or die(mysql_error());
    $data = mysql_fetch_array($query);
    if($data['password'] != $password) {
    include('../loginerror.php');
    }else{
    $query = mysql_query("SELECT email,password,username FROM accounts WHERE email='$email'") or die(mysql_error());
    $row = mysql_fetch_array($query);
    $_SESSION["account"] = $row['username'];
    echo "<meta http-equiv=Refresh content=1;url=members.php>";
    }
    }
    }
    ?>
    
    PHP:
    But its giving me the error:

    Whats wrong with it? I know its connecting to the database because i have other code requesting information from the database. I also am using the same code on another website on the same server and it works, so i have no idea whats wrong.
     
    killaklown, Aug 29, 2006 IP
  2. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #2
    you didn't connect to your database ....

    put these two line ( u need to modify your variable)

    mysql_connect($hostname,$dbusername,$dbpassword)
    or die("Could not connect to DataBase");
    mysql_select_db($dbname) or die("Could not find DB");
     
    ahkip, Aug 29, 2006 IP
  3. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #3
    heh, stuiped me forgot to put in <? include 'connect.php'; ?>


    I think its time to go get some rest.
     
    killaklown, Aug 29, 2006 IP