Re: newbie question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Maybe you should use the char ' in the values:
("INSERT INTO users (nick, email, pw) VALUES('$nick', '$mail', '$pw');");

You should also copy and paste the error you are getting.

Bye!


----------------------------------------------
Atentamente/Best regards

Rafael Mora
Cel/Mob: +58-414-493.31.39
Cel/Mob: +57-321-755.37.69
Twitter @titanve


On Mon, Aug 3, 2020 at 8:06 PM Fernando Fiore <no5software@xxxxxxxxx> wrote:
why this simple database operation does not work
function AddToUsersTable($mail,$nick,$pw) // $mail is an email add
{
    $db = new mysqli("localhost","root","","mydb");
    
    if($db){
        $mail = $db->real_escape_string($mail);
        //print($mail . "</br>");
        $nick = $db->real_escape_string($nick);
        $pw = $db->real_escape_string($pw);
        $q = $db->query("INSERT INTO users (nick, email, pw) VALUES($nick, $mail, $pw);");
        if($q)
            return true;
        else{ /* it fails here *;
            print($db->error);
            return false;
        }
        
    }
    else{
        print("failed to connect to db </br>");
        return false;
    }
        
}
// thanks in advance

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux