Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE `prob` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `key` VARBINARY(4) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_general_ci;
- INSERT INTO `prob` ( `key` ) VALUES ( 0x1234 );
- $key = pack( "H*", '01020304' );
- if( $stmt = $con->prepare("INSERT INTO prob VALUES ( DEFAULT, ? )") ) {
- $stmt->bind_param( "s", $key );
- $stmt->execute( );
- $stmt->close( );
- } else { $err = $con->error; echo "Err $err<br>"; }
- if( $stmt = $con->prepare("SELECT id FROM prob WHERE key='?'") ) {
- if( !$stmt->bind_param( "s", $key ) ) {echo 'Err bind_param.<br>'; die( );}
- if( !$stmt->execute( ) ) {echo 'Err execute.<br>'; die( );}
- if( !$stmt->bind_result( $id ) ) {echo 'Err bind_result.<br>'; die( );}
- $rv = $stmt->fetch( );
- $stmt->close( );
- echo 'Result: '.print_r( $rv ).'<br>';
- } else { $err = $con->error; echo "Err $err<br>"; }
- if($result = $con->query( "SELECT id FROM prob WHERE key=$key" )) {
- if( $count = $result->num_rows == 1 ) {
- $row = $result->fetch_row( );
- $rv = $row[0];
- $result->close( );
- }
- } else { $err = $con->error; echo "Err $err<br>"; }
Add Comment
Please, Sign In to add comment