php - Unable to insert data into mysql using sprintf -


i'm unable find made mistake here: not insert data database when use sprintf particular query while others can! data type now() , 0 value correct below?

$query2=sprintf("insert usrinfo (uuid,name,phone,email,postcode,datereg,reputation,reviewplus,reviewneg,sex,status,contactpermissions)values('%s','%s','%s','%s','%s','%s','%u','%u','%u','%s','%u','%u')",$unique_id,$name,$phone,$email,$postcode,now(),0,0,0,$gender,0,$permission);  $insert2=mysqli_query($conn,$query2)or die(mysqli_error($conn)) 

but when don't use sprintf, works! below query without sprintf

$query2="insert usrinfo (uuid,name,phone,email,postcode,datereg,reputation,reviewplus,reviewneg,sex,status,contactpermissions) values('$unique_id','$name','$phone','$email','$postcode',now(),'0','0','0','$gender','0','$permission')"; 

there mismatch of data type defining in string see below list of different params use define different data type :--

% - literal percent character. no argument required.

b - argument treated integer, , presented binary number.

c - argument treated integer, , presented character ascii value.

d - argument treated integer, , presented (signed) decimal number.

e - argument treated scientific notation (e.g. 1.2e+2). precision specifier stands number of digits after decimal point since php 5.2.1. in earlier versions, taken number of significant digits (one less).

e - %e uses uppercase letter (e.g. 1.2e+2).

f - argument treated float, , presented floating-point number (locale aware).

f - argument treated float, , presented floating-point number (non-locale aware). available since php 4.3.10 , php 5.0.3.

g - shorter of %e , %f.

g - shorter of %e , %f.

o - argument treated integer, , presented octal number.

s - argument treated , presented string.

u - argument treated integer, , presented unsigned decimal number.

x - argument treated integer , presented hexadecimal number (with lowercase letters).

x - argument treated integer , presented hexadecimal number (with uppercase letters).


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -