Jump to content

ChaosKnight

Members
  • Posts

    183
  • Joined

  • Last visited

    Never

Everything posted by ChaosKnight

  1. Hi, this code is supposed to update a hotel entry, but each time I try to run it, it says that it doesn't update... <?php //DB works, so that code is left out if(isset($_GET['id'])){ $id = $_GET['id']; } if(isset($_POST['submit'])){ //code that works is left out... $logoTxt = $_POST['logo']; $image1Txt = $_POST['image1']; $image2Txt = $_POST['image2']; $allowedExtensions = array("png","jpg","jpeg","gif"); if((isset($_FILES['logoUpload']))&&($_FILES['logoUpload']['tmp_name'] > '')){ // logo upload code works $logo = $_FILES['logoUpload']['name']; }else{ $logo = $logoTxt; } if((isset($_FILES['image1Upload']))&&($_FILES['image1Upload']['tmp_name'] > '')){ // image1 upload code works $image1 = $_FILES['image1Upload']['name']; }else{ $image1 = $image1Txt; } if((isset($_FILES['image2Upload']))&&($_FILES['image2Upload']['tmp_name'] > '')){ // image2 upload code works $image2 = $_FILES['image2Upload']['name']; }else{ $image2 = $image2Txt; } if((isset($image1))&&(isset($image2))&&(isset($logo))){ $sql = "UPDATE hotels name='$name', description='$description', location='$location', country_id='$country_id', country='$country_name', province_id='$province_id', province='$province_name', town_id='$town_id', town='$town_name', city_id='$city_id', city='$city_name', park_id='$park_id', park='$park_name', languages='$languages', logo='$logo', logo_width='$logo_width', logo_height='$logo_height', image1='$image1', image2='$image2', homepage='$homepage', active='$active', type='$type' WHERE `id`='".$id."'"; }elseif((isset($image1))&&(isset($image2))){ $sql = "UPDATE hotels name='$name', description='$description', location='$location', country_id='$country_id', country='$country_name', province_id='$province_id', province='$province_name', town_id='$town_id', town='$town_name', city_id='$city_id', city='$city_name', park_id='$park_id', park='$park_name', languages='$languages', image1='$image1', image2='$image2', homepage='$homepage', active='$active', type='$type' WHERE `id`='".$id."'"; }elseif((isset($image1))&&(isset($logo))){ $sql = "UPDATE hotels name='$name', description='$description', location='$location', country_id='$country_id', country='$country_name', province_id='$province_id', province='$province_name', town_id='$town_id', town='$town_name', city_id='$city_id', city='$city_name', park_id='$park_id', park='$park_name', languages='$languages', logo='$logo', logo_width='$logo_width', logo_height='$logo_height', image1='$image1', homepage='$homepage', active='$active', type='$type' WHERE `id`='".$id."'"; }else{ $sql = "UPDATE hotels name='$name', description='$description', location='$location', country_id='$country_id', country='$country_name', province_id='$province_id', province='$province_name', town_id='$town_id', town='$town_name', city_id='$city_id', city='$city_name', park_id='$park_id', park='$park_name', languages='$languages', homepage='$homepage', active='$active', type='$type' WHERE `id`='".$id."'"; } if(mysql_query($sql, $db_link)){ echo "<h3>The hotel was updated successfully...</h3>"; }else{ echo "<h3>The hotel could not be updated...</h3>"; } } ?> Can anyone see what I did wrong??
  2. In your SQL? If that's the case, then you can set the table type as a timestamp and the default value as 0000-00-00 for yyyy-mm-dd, you can also do the time 0000-00-00 00:00:00
  3. What about this: function addDate($date,$day)//add days { $sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days"); $dateTo=date('Y-m-d',$sum); return $dateTo; } then you can call it like this: $est = addDate($today,7);
  4. Have you tried this?: <?php $today = $row_last_picture_date['user_picture_date']; $est = date(“d/m/Y”,strtotime(“+7 days”,$today)); print date('d/m/Y', $est); ?> The code you had a problem with adds 7 days to the date in the db, do you want code that adds 7 days to the current date?
  5. Thanks mate!! You have an eagle's eye lol ... SOLVED!
  6. Try this: $picturedate = $row_last_picture_date['startdate']; $date = date(“Y m d”,strtotime(“+7 days”,$picturedate));
  7. Yesterday I had a lot of drama with creating a file uploader, but it finally works... Now I had to make alternatives to the file upload, because every hotel has a lot of properties and I don't want to have a hundred or so files of the same image, so I inserted this in the form: <input type="text" id="logoExists" name="logoExists" /> And this PHP code to handle the extra field: if(isset($_POST['submit'])){ $logoExists = $_POST['logoExists']; $allowedExtensions = array("png","jpg","jpeg","gif"); if(($logoExists = '')||($logoExists = null)){ if((isset($_FILES['logo']))&&($_FILES['logo']['tmp_name'] > '')){ if(!in_array(end(explode(".",strtolower($_FILES['logo']['name']))),$allowedExtensions)){ die($_FILES['logo']['name'].' has an invalid file type...<br/>'); }else{ $target_path = "images/logos/"; $target_path = $target_path . basename($_FILES['logo']['name']); if(move_uploaded_file($_FILES['logo']['tmp_name'], $target_path)){ echo "<h3>{$_FILES['logo']['name']} uploaded successfully...</h3><br />"; $logo = $_FILES['logo']['name']; }else{ echo "<h3>{$_FILES['logo']['name']} could not be uploaded...</h3><br />"; } } } }else{ $logo = $logoExists; } But it seems like when I leave out the file and insert the text into the logoExists field, that PHP simply ignores all that PHP code... Can anyone see my mistake?? Thanks
  8. Everything works perfectly now... SOLVED!!
  9. Didn't seem to work... I'll wait for their e-mail about my permissions... Thanks for your help, I'm going to take a break now and watch some South Park and then I'll try again haha... Thanks for all your help eagle...
  10. I sent an e-mail to my host and asked them to check my permissions, they'll probably reply within the next 6 hours, I don't know what the time in the US is now, but here in South Africa it's 8:43PM, so it's probably somewhere around 9AM there... I'm busy downloading FileZilla now, will try it instead of CuteFTP... How can I create a directory via PHP?
  11. I use CuteFTP, when I tried to change the CHMOD, it informed me that the command is not understood by the server... Is CHMOD only for Linux servers? Because a few times before I thought that my web host has Windows Servers, if that's the case then it will explain everything... The server I'm on also has a lot of downtime... And the webhost only gives support for ASP so they'll never assist me...
  12. But that will enable everyone to upload anything to that folder? I use CuteFTP, when I tried to change the CHMOD, it informed me that the command is not understood by the server... Is CHMOD only for Linux servers? Because a few times before I thought that my web host has Windows Servers, if that's the case then it will explain everything... The server I'm on also has a lot of downtime... And the webhost only gives support for ASP so they'll never assist me...
  13. It only changes the following: " " (ASCII 32 (0x20)), an ordinary space. "\t" (ASCII 9 (0x09)), a tab. "\n" (ASCII 10 (0x0A)), a new line (line feed). "\r" (ASCII 13 (0x0D)), a carriage return. "\0" (ASCII 0 (0x00)), the NUL-byte. "\x0B" (ASCII 11 (0x0B)), a vertical tab.
  14. Is this what you are looking for?: $_SERVER['PHP_SELF'];
  15. Can you please direct me to where the login script is, because I can only find a registration script... Or is that the script we should take a look at?
  16. I never used chmod() before, so I don't really know what to do... I looked at the PHP Manual , and it said that this should work: $target_path = chmod("images/hotels/", 0777); But then I tried it, and it returned this error message: Warning: chmod() [function.chmod]: Permission denied in *address* on line 8 So I guess I can't use chmod then?
  17. I simplified the code to only: <?php $allowedExtensions = array("png","jpg","jpeg","gif"); if(isset($_FILES['image1'])){ if($_FILES['image1']['tmp_name'] > ''){ if(!in_array(end(explode(".",strtolower($_FILES['image1']['name']))),$allowedExtensions)){ die($_FILES['image1']['name'].' has an invalid file type...<br/>'); }else{ $target_path = "images/hotels/"; $target_path = $target_path . basename($_FILES['image1']['name']); if(move_uploaded_file($_FILES['image1']['tmp_name'], $target_path)){ echo "<h3>$_FILES['image1']['name'] uploaded successfully...</h3>"; } } } } ?> Now it runs the code successfully, but it gives me these messages: Warning: move_uploaded_file(images/hotels/ph-hazyview-gardens.jpg) [function.move-uploaded-file]: failed to create stream: Permission denied in *web address* on line 10 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\PHP\uploadtemp\php154.tmp' to 'images/hotels/ph-hazyview-gardens.jpg' in *web address* on line 10 Is there some kind of setting that I have to enable in php.ini? If there is, what will the code be to change it on runtime, because I'm on a shared host, so I don't know if they enabled it or not...
  18. I found this for you, hope this is what you need: http://www.php.net/manual/en/function.imap-fetch-overview.php#73891 If you need a pagination script, I can provide one for you that is very effective, I use it all the time...
  19. I don't know how to limit them, but what I do know is you can use the following to filter the results: ALL - return all messages matching the rest of the criteria ANSWERED - match messages with the \ANSWERED flag set BCC "string" - match messages with "string" in the Bcc: field BEFORE "date" - match messages with Date: before "date" BODY "string" - match messages with "string" in the body of the message CC "string" - match messages with "string" in the Cc: field DELETED - match deleted messages FLAGGED - match messages with the \FLAGGED (sometimes referred to as Important or Urgent) flag set FROM "string" - match messages with "string" in the From: field KEYWORD "string" - match messages with "string" as a keyword NEW - match new messages OLD - match old messages ON "date" - match messages with Date: matching "date" RECENT - match messages with the \RECENT flag set SEEN - match messages that have been read (the \SEEN flag is set) SINCE "date" - match messages with Date: after "date" SUBJECT "string" - match messages with "string" in the Subject: TEXT "string" - match messages with text "string" TO "string" - match messages with "string" in the To : UNANSWERED - match messages that have not been answered UNDELETED - match messages that are not deleted UNFLAGGED - match messages that are not flagged UNKEYWORD "string" - match messages that do not have the keyword "string" UNSEEN - match messages which have not been read yet You could use SINCE and limit them that way... Maybe there is some hack available to do what you want it to do?
  20. This is how I post the images: <input type="file" id="logo" name="logo" /> <input type="file" id="image1" name="image1" /> <input type="file" id="image2" name="image2" /> So the 'file' in $_FILES['file'] can only be logo, image1 and image2. The rest of the image's attributes are unknown, seeing that it's a form to create a new hotel entry for a tourism company... I don't know if that's where I made a logical error by using: foreach($_FILES as $file) Because I read somewhere just now that the $_FILES global is an associative array, so should I use foreach($_FILES as $key => $value) instead? I'm still confused with associative arrays, because I prefer the normal array... I don't think it passes as a multi dimensional array
  21. If the different values are very limited and you only have this single range, then an "if" will be a better option, if there are a lot of different ranges, then a case will be the best tool for the job... But both will work
  22. Try this: switch($num){ case $num > 50 && $num < 150 : //action goes here break; }
  23. Still nothing after the code by the eagle... I changed the code to this: <?php $allowedExtensions = array("png","jpg","jpeg","gif"); foreach ($_FILES as $file){ if($file['tmp_name'] > ''){ if(!in_array(end(explode(".",strtolower($file['name']))),$allowedExtensions)){ die($file['name'].' has an invalid file type...<br/>'); }else{ if($file == 'logo'){ $target_path = "images/logos/"; $target_path = $target_path . basename($file['name']); move_uploaded_file($file['tmp_name'], $target_path); }elseif(($file == 'image1') || ($file == 'image2')){ $target_path2 = "images/hotels/"; $target_path2 = $target_path . basename($file['name']); if(move_uploaded_file($file['tmp_name'], $target_path2)){ echo "<h3>$file['name'] uploaded successfully...</h3>"; }else{ echo "3"; } }else{ echo "2"; } } }else{ echo "1"; } } ?> With the hope that it'll clarify what happens in the code, and it returned 121... So it finds an error at if($file['tmp_name'] > '') and at if($file == 'logo) and the other 2 file checks, and then again at the if(file['tmp_name'] > '') I don't want to check the name of the file, I just want to check from which file input it was submitted... On the previous form I have 3 file inputs: logo, image1 and image2, that is the reason why I need to check where it came from...
  24. I made this code that is supposed to upload an image to the server under the specified target path, but it doesn't want to... <?php $allowedExtensions = array("png","jpg","jpeg","gif"); foreach ($_FILES as $file){ if($file['tmp_name'] > ''){ if(!in_array(end(explode(".",strtolower($file['name']))),$allowedExtensions)){ die($file['name'].' has an invalid file type...<br/>'); }else{ if($file == 'logo'){ $target_path = "images/logos/"; $target_path = $target_path . basename($file['name']); move_uploaded_file($file['tmp_name'], $target_path); }elseif(($file == 'image1') || ($file == 'image2')){ $target_path = "images/hotels/"; $target_path = $target_path . basename($file['name']); move_uploaded_file($file['tmp_name'], $target_path); } } } } ?> What did I do wrong? The reason why I check whether it's logo, image1, or image2 is because they go into different directories. Any help will be greatly appreciated
  25. Is there books available about the most advanced PHP topics, such as e-mail piping, PHP shell, using C with PHP, etc.? I hear a lot of PHP experts talking about thing like those, and that makes me feel like somewhere along the line I missed something that I should have known already...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.