I'm converting several mysql statements over to procedural prepared statements in PHP and everything has been going fine until I tried to bind an email address to a mysqli_stmt_bind_param. I have used this website for years, but this is my first post because I can truly not find an answer to this issue.
$stmt = mysqli_prepare($rw_link, "INSERT INTO user (gid,name,email) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'sss', $gpl_id, $gpl_displayName, $gpl_email);
$gpl_id="1111";
$gpl_displayName="Test Name";
$gpl_email="test@test.com";
mysqli_stmt_execute($stmt);
printf("%d Row inserted.
", mysqli_stmt_affected_rows($stmt));
1 row is inserted. What is inserted is the id and name but the email is just a "0". I have seen other examples of people using emails here and i have literally copied the code and I am having the same issue.
Datatype is varchar(55) Table: http://cl.ly/image/2r1H1k203G1U
If a number is inserted it updates the value..
mysqli_stmt_bind_param($stmt, 'sss', $gpl_id, $gpl_displayName, $gpl_email);
$gpl_id="1111";
$gpl_displayName="Test Name";
//$gpl_email="test@test.com";
$gpl_email="12345";
mysqli_stmt_execute($stmt);
If the insert statement is not prepared, it inserts the email properly:
$sql="INSERT INTO user (gid,name,email) values ('" . $gpl_id . "','" . $gpl_displayName . "','" . $gpl_email . "')";
mysqli_query($rw_link,$sql) or die(mysqli_error($rw_link));