Check to see if an email is already in the database using prepared statements

Should be something like this: // enable error reporting for mysqli mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // create mysqli object $mysqli = new mysqli(/* fill in your connection info here */); $email = $_POST[’email’]; // might want to validate and sanitize this first before passing to database… // set query $query = “SELECT COUNT(*) FROM users WHERE … Read more

ODBC prepared statements in PHP

Try removing the single quotes from the query string and adding them to the parameter value itself: $pstmt=odbc_prepare($odb_con,”select * from configured where param_name=?”); $res=odbc_execute($pstmt,array(” ‘version'”)); var_dump($res); //bool(true) $row = odbc_fetch_array($pstmt); var_dump($row); //bool(false) The single space character at the beginning of the parameter value is very important–if the space is not there, it will treat the … Read more

PreparedStatement and setTimestamp in oracle jdbc

To set a timestamp value in a PreparedStatement in UTC timezone one should use stmt.setTimestamp(1, t, Calendar.getInstance(TimeZone.getTimeZone(“UTC”))) The Timestamp value is always UTC, but not always the jdbc driver can automatically sent it correctly to the server. The third, Calendar, parameter helps the driver to correctly prepare the value for the server.

JDBC Prepared Statement . setDate(….) doesn’t save the time, just the date.. How can I save the time as well?

Instead of Date you should use a Timestamp and the setTimestamp method. pratically you have to do something like that: private static java.sql.Timestamp getCurrentTimeStamp() { java.util.Date today = new java.util.Date(); return new java.sql.Timestamp(today.getTime()); } …. preparedStatement.setTimestamp(4,getCurrentTimeStamp());

How to run the bind_param() statement in PHP?

When binding parameters you need to pass a variable that is used as a reference: $var = 1; $stmt->bind_param(‘i’, $var); See the manual: http://php.net/manual/en/mysqli-stmt.bind-param.php Note that $var doesn’t actually have to be defined to bind it. The following is perfectly valid: $stmt->bind_param(‘i’, $var); foreach ($array as $element) { $var = $element[‘foo’]; $stmt->execute(); }