Thanks I really appreciate
But is it possible to use SQL to count the number of times the user have uploaded previously, then check it from the location and pass the error?
yes it is but, you allow currently SQL injections in your code. i can create a file with SQL Code in the name and can inject it into your database.
And also the ID.
First your SQL Command should look like this
$sql="INSERT INTO business(image,id) VALUES(?,?) ON DUPLICATE KEY UPDATE image = VALUES(image)";//Here we send the SQL to the database and say that in ? those are variables$statement=mysqli_prepare($conn,$sql);//Here we send the variables in extra function so the database can "secure" them. we also say what kind of variables this is, s = string, i= integer, so filename should be a text and id should be a numbermysqli_stmt_bind_param($conn,"si",$filename,$id);mysqli_stmt_execute($statement);//now we can execute the SQL in the database with secure variables
this way you will produce multiple entries in your Database. now you can call following SQL before your script starts
$sql="SELECT COUNT(filename) as countFiles FROM business WHERE id = ?
LIMIT 1
";$statement=mysqli_prepare($conn,$sql);mysqli_stmt_bind_param($conn,'i',$id);mysqli_stmt_execute($statement);$result=mysqli_stmt_get_result($statement);$dataFromDatabase=mysqli_fetch_assoc($result);$limitReached=$dataFromDatabase['countFiles']>4;if($limitReached){//TODO}
Thanks I really appreciate
But is it possible to use SQL to count the number of times the user have uploaded previously, then check it from the location and pass the error?
yes it is but, you allow currently SQL injections in your code. i can create a file with SQL Code in the name and can inject it into your database.
And also the ID.
First your SQL Command should look like this
this way you will produce multiple entries in your Database. now you can call following SQL before your script starts
II really thank you vary much, u are the best