i got an db that i can add stuff in it with this sql statement using pdo type of connection .. :
$sql_createAD = "INSERT INTO `kijilikedb`.`advertise` (`AD_ID`, `AD_NAME`, `REF_STATE`, `REF_USER`, `REF_CAT`, `REF_SUB`, `REF_DESC`, `REG_DATE`, `EXP_DATE`, `AD_TYPE`, `AD_PRICE` , `IMAGE`) VALUES (NULL,'".$_POST['Title']."','".$_POST['state']."','',".$currentCAT.",'".$_POST['sub']."', ".$currentDescId.", '".$today."', '".$EXP."','".$_POST['type']."','".$_POST['Price']."','".mysql_real_escape_string(file_get_contents($_FILES['image']['tmp_name']))."')";
$con->query($sql_createAD );
in big ..... im adding an article that contain information and everyting .... but when im adding the img to the database im using ".mysql_real_escape_string" that is a depreciated methode that i should use anymore ...... so now i want to replace it ... but i read there is no alternative for this in pfo ...... but im shure i can find an work around it ..... so plz help me finding it! :D
i find that maybe if im using an $con->prepare() for the insert and execute() for puting it in the db it could work ... but in doest for me ..... the error i get when i doing is : SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
look at the try i did :
$query = "INSERT INTO `kijilikedb`.`advertise` (`AD_ID`, `AD_NAME`, `REF_STATE`, `REF_USER`, `REF_CAT`, `REF_SUB`, `REF_DESC`, `REG_DATE`, `EXP_DATE`, `AD_TYPE`, `AD_PRICE` , `IMAGE`) VALUES (NULL,'".$_POST['Title']."','".$_POST['state']."','',".$currentCAT.",'".$_POST['sub']."', ".$currentDescId.", '".$today."', '".$EXP."','".$_POST['type']."','".$_POST['Price']."','".file_get_contents($_FILES['image']['tmp_name'])."')";
$preparedQuery = $con->prepare($query);
$preparedQuery->execute();