i cant find what's wrong with the coding, here is my coding:
daftar( cucidata( $_POST["username"]),
cucidata($_POST["password1"]),
cucidata($_POST["password2"]),
cucidata($_POST["name"]),
cucidata($_POST["email"]),
$_FILES["photo"]["name"],
$con,
$_FILES["photo"]["tmp_name"],
cucidata($_POST["dob"]),
cucidata($_POST["gender"]),
cucidata($_POST["hp"]),
cucidata($_POST["address"]),
cucidata($_POST["university"]),
cucidata($_POST["gd"]),
cucidata($_POST["qualitification"]),
cucidata($_POST["fos"]),
cucidata($_POST["mos"]),
cucidata($_POST["ai"]),
cucidata($_POST["jt"]),
cucidata($_POST["cn"]),
cucidata($_POST["pe1"]),
cucidata($_POST["pe2"]),
($_FILES["resume"]["name"]),
$con,
$_FILES["resume"]["tmp_name"]
);
//save the resume to blob
$resumeFileType = strtolower(pathinfo($resume,PATHINFO_EXTENSION)); //dapatkan jenis resume
$resumeData =addslashes(file_get_contents($resumeFileType));
$resumeProperties = getimageSize($resumeFileType);
mysqli_query($con,"INSERT INTO tbl_user
(username,pwd,name,email,picture,pictype,
dob,gender,hp,address,university,gd,
qualitification,fos,mos,ai,jt,cn,pe1,pe2,
resume,resumetype)
values ('$user','$pwd','$name','$email','{$imgData}',
'{$imageProperties['mime']}','$dob','$gender',
'$hp','$address','$university','$gd',
'$qualitification','$fos','$mos','$ai',
'$jt','$cn','$pe1','$pe2','{$resumeData}',
'{$resumeProperties['mime']})")
or die (mysqli_error($con));
this is the result:
Warning: file_get_contents(pdf): failed to open stream: No such file or directory in C:\laragon\www\intern\include\main_function.php on line 38
Warning: getimagesize(pdf): failed to open stream: No such file or directory in C:\laragon\www\intern\include\main_function.php on line 39
Notice: Trying to access array offset on value of type bool in C:\laragon\www\intern\include\main_function.php on line 42 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 1
could someone enlighten me regarding this issue?
Use $_FILES["resume"]["tmp_name"]
instead of the file extension for file_get_contents()
. Also, don't use getimagesize()
as resumes are generally not images. You can get the MIME type with the finfo_open()
and finfo_file()
functions. Try updating your code to read the resume file contents using the temporary path and keep the MIME type.
Also, try using a beautifier before posting code as it makes it easier to read. Here's one I found for PHP: https://codebeautify.org/php-beautifier.