Jump to content
Larry Ullman's Book Forums

bahaa

Members
  • Posts

    147
  • Joined

  • Last visited

Everything posted by bahaa

  1. I figured it out INSERT INTO wine(wineID, wineYear, wineName, winePrice, wineHarvest) SELECT 1+ (SELECT MAX(wineID) FROM wine), 2009, 'Vidal icewine', 13.5, '2010-01-29';
  2. //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)){
  3. 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'])){
  4. I am not trying to retrieve the last id I inserted. I want to insert a new record into a table and used the next available id for a field that is not auto increment. All I am tasking is that if there is a function to be used within the insert statement to insert the next available id.
  5. The table she gave us contains 23 records, so I need to insert the record number 24, but I want to be able to insert id 24 without going back to the table and look what was the last record. Is there a function to do that in the insert statement?
  6. 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,
  7. Hello everybody, From security and efficiency prospective, what is best to use for the visible field column in database? enum('yes', 'no') or INT 1 for visible and 0 for invisible? Regards,
  8. 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?
  9. Hello, I want to upload two files with different extension at once, and I want each one of them to be stored in the database in different row. Does any body know how to handle that ? regards,
  10. Hello, I want to display the date in Arabic. Is there a function to convert the day of the week and month into Arabic? PHP Version 5.3.0 Regards,
  11. I am not using the Object oriented style in my code. Do you know to to check for the num rows and fetching the array not using the Object oriented style?
  12. I am sorry if I did not give enough information. I know to to write the statement, but I dont know how to check for the num rows and how to fetch it. here is my code as you see the code is missing the part where to check the num rows, fetching it, and redirect the user
  13. Hello, Does any one know how to check login using prepared statement? help appreciated
  14. I don't have any problem with the connection. I have other queries on the same page and they work fine.
  15. i get this error mysqli_bind_param() expects parameter 1 to be mysqli_stmt, boolean given
  16. 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?
  17. I am sorry , I really did not explain what I need. I want to use the prepared select statement
  18. I am making a registration page and I need to use the select statement to check if username exists or not, so in this case I need to escape the value coming from the user.
×
×
  • Create New...