c# - PHP Prepared Statments - Can't Select Varchar Rows, No Problems Selecting Numeric Rows -
alright, i'm having oddball problem here. i'm trying select row via php, reason won't grab row data! it's not having problems fetching numeric rows or anything.
note: sending arguments via c# winform, cause of problem (collation or something)?
$stmt_getsalt = $con->prepare("select salt,status accounts email=?"); $stmt_getsalt->bind_param("s", $email); $stmt_getsalt->execute(); $stmt_getsalt->bind_result($salt, $status); $stmt_getsalt->fetch(); $stmt_getsalt->close();
status int
, has no problem returning value. salt varchar
no data being returned. what's going on here?
edit: xml representation of data in table.
<table name="accounts"> <column name="email">test@testmail.test3</column> <column name="password">65t6anolesrba</column> <column name="salt">65fe93d93e283f002beaca712fd178c6</column> <column name="pin">81dc9bdb52d04dc20036dbd8313ed055</column> <column name="status">0</column> <column name="id">5</column> </table>
edit 2: fixed problem. instantiating $email
after binding params. statement trying bind parameter did not yet exist. shouldn't code late @ night.
i cannot reproduce problem
<?php mysqli_report(mysqli_report_strict); $mysqli = new mysqli('localhost', 'localonly', 'localonly', 'test'); setup($mysqli); var_export( foo($mysqli, 'test@testmail.test3') ); function foo($con, $email) { $stmt_getsalt = $con->prepare("select salt,status sofoo email=?"); $stmt_getsalt->bind_param("s", $email); $stmt_getsalt->execute(); $stmt_getsalt->bind_result($salt, $status); $stmt_getsalt->fetch(); $stmt_getsalt->close(); return array('salt'=>$salt, 'status'=>$status); } function setup($mysqli) { $mysqli->query(' create temporary table sofoo ( salt varchar(32), status int, email varchar(32) ) '); $mysqli->query(" insert sofoo (salt,status,email) values ('65fe93d93e283f002beaca712fd178c6', 0, 'test@testmail.test3') "); }
prints
array ( 'salt' => '65fe93d93e283f002beaca712fd178c6', 'status' => 0, )
as expected.
Comments
Post a Comment