Not working:
$link = mysqli_connect("localhost", "********", "*******", "*******");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$cmp = 126;
if (($stmt = mysqli_prepare($link, "SELECT datalock FROM sys_tenancy WHERE id=?"))) {
echo mysqli_stmt_bind_param($stmt, "i", $cmp) ? '1':'0';
echo mysqli_stmt_execute($stmt) ? '1':'0';
echo mysqli_stmt_bind_result($stmt, $datalock) ? '1':'0';
echo mysqli_stmt_fetch($stmt) ? '1':'0';
printf("%s: %s\n", $cmp, $datalock);
mysqli_stmt_close($stmt);
}
mysqli_close($link);
output:
1110 126: 0
Working:
$link = mysqli_connect("localhost", "********", "*******", "*******");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//$cmp = 126;
if (($stmt = mysqli_prepare($link, "SELECT datalock FROM sys_tenancy WHERE id=126"))) {
//echo mysqli_stmt_bind_param($stmt, "i", $cmp) ? '1':'0';
echo mysqli_stmt_execute($stmt) ? '1':'0';
echo mysqli_stmt_bind_result($stmt, $datalock) ? '1':'0';
echo mysqli_stmt_fetch($stmt) ? '1':'0';
printf(" %s: %s\n", $cmp, $datalock);
mysqli_stmt_close($stmt);
}
mysqli_close($link);
output:
111 126: 1
What I need is the first one to work. I have mysql 4.1.22 and php 5.2.13