bahaa
Members-
Posts
147 -
Joined
-
Last visited
Everything posted by bahaa
-
//Move the file over if(is_uploaded_file($_FILES['photo']['tmp_name'])){ if(move_uploaded_file($temp_photo_filename, $target_path.$photo_file_name)){ if(file_exists($target_path. $photo_file_name)){ $unique_photo_name = uniqid(md5(time())).".".$photo_file_extension; rename($target_path.$photo_name, $target_path.$unique_photo_name); }//if(file_exists($target_path. $photo_file_name)){
-
this is how i do it // check for an image if(is_uploaded_file($_FILES['photo']['tmp_name'])){ //Create a temporary file name $target_path = "../uploads/"; $photo_name = strtolower($_FILES['photo']['name']); $temp_photo_filename = $_FILES['photo']['tmp_name']; $photo_file_size = $_FILES['photo']['size']; $photo_file_type = strtolower($_FILES['photo']['type']); $photo_file_extension = strtolower(substr(strchr($_FILES['photo']['name'],'.'), 1)); $imageInfo = getimagesize($temp_photo_filename); $imageInfo = $imageInfo['mime']; //Convert all applicable characters to HTML entities $photo_file_name = htmlentities($photo_name); $photo_file_type = htmlentities($photo_file_type); $allowed = array('image/pjepg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif', 'image/GIF'); if(!in_array($photo_file_type, $allowed)){ $errors[]="<p>إمتداد الملف الذي قمت بتحميله غير مصرح به.</p>"; }// end of if(in_array($_FILES['upload']['type'], $allowed)){ if(!is_numeric($photo_file_size)){ $errors[]="<p>نوع الملف الذي تحاول تحميله غير معروف</p>"; }//if(!is_numeric($photo_file_size)){ }//if(is_uploaded_file($_FILES['photo']['tmp_name'])){
-
Hello, How do I insert the next available id for a field if it is not auto increment? Is there a function I can use within the insert statement to get the last id and increment it by one? I was trying this INSERT INTO wine(wineID, wineYear, wineName, winePrice, wineHarvest) VALUES((select(MAX(wineID)+1) FROM wine ), 2009, 'Vidal icewine', 13.5, '2010-01-29'); But It did not work. It said, Error Code: 1093. You can't specify target table 'wine' for update in FROM clause I know you would say why just don't you use auto increment on the id field This table was given to us by the teacher in school and she did not auto increment the id field. Regards,
-
My problem is with handling the multi upload not with the query I am trying this but i am getting Notice: Undefined offset: 2 in C:\wamp\www\Site\htdocs\admin\upload1.php on line 33 Notice: Undefined offset: 2 in C:\wamp\www\Site\htdocs\admin\upload1.php on line 34 Can any body point out where is my mistake?
-
I already know how to use the insert and update prepare statement, but for some reason I can't use the select one. I searched on the internet and followed the instruction but it fives me an error. This is what I want to do $Q = " SELECT username FROM users Where username = '$username' "; $R = mysqli_query($con, $Q); if(mysqli_num_rows($R) !=0){ echo "The username you have chosen already taken"; } Can any one rewrite it using the prepared statement?