Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP MySQLi

Name: DOMMIT FRONK 2013-02-16 17:20

   
$username = $_POST['username'];
    $pass = $_POST['password'];
   
    //Connect to MySQL
    $mysqli = new mysqli("localhost", "username", "password", "databasename");
    if ($mysqli->connect_errno)
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
   
    //Validate user
    $query = "SELECT Hash, Salt FROM USERS WHERE UserName = ?";
    $stmt = $mysqli->prepare($query);
    $stmt->bind_param('s', $username);
    $stmt->execute();
    $stmt->bind_result($userHash, $userSalt);
    $stmt->close();
        $mysqli->close();


I use pretty much the exact same format to perform inserts into this table (which works just fine), but for some reason $userHash and $userSalt always end up null, what gives? D:

This is the beginning of my validation upon login, which is hard to do when the select query isn't giving me anything >_<

Name: Anonymous 2013-02-16 17:33

Read the fucking documentation. What do you think bind_result does? Hint: it's not fetch data.

This isn't Stack Overflow.

Name: Anonymous 2013-02-16 17:48

Nice option: do >>2.

Bad option: kill yourself for using PHP.

Best option: code in another env., dissade or leave the job.

Name: Anonymous 2013-02-16 17:59

>>2
"Binds columns in the result set to variables."

This quote is straight FROM THE DOCUMENTATION:

http://php.net/manual/en/mysqli-stmt.bind-result.php


>>3
PHP isn't a shit language, and this isn't for a job.

Name: Anonymous 2013-02-16 18:11

>>4
Look at the fucking code samples to see how it's actually used. Notice the method call there that isn't in your code.
Jesus fuck.

Name: Anonymous 2013-02-16 18:13

>>4
PHP isn't a shit language, and this isn't for a job.
Why did you come to /prog/? You're never going to be a programmer.

Name: Anonymous 2013-02-16 19:35

Not even a thank you, then? Fuck you too, PHP moron.

Don't change these.
Name: Email:
Entire Thread Thread List