Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Instead of a random names? Change //save image thumbnail ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); // upload original file move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext"); // add image thumbnail to array $uploaded_images[] = $rand_name.$file_ext; to //save image thumbnail ImageJpeg ($resized_img, "$path_thumbs/$file_name"); ImageDestroy ($resized_img); ImageDestroy ($new_img); // upload original file move_uploaded_file ($file_tmp, "$path_big/$file_name"); // add image thumbnail to array $uploaded_images[] = $file_name; Now the actual filename of the images should be preserved
  2. I accidently deleted it change $name = $_POST["name"]; $description = $_POST["description"]; To $name = $_POST["name"]; $description = $_POST["description"]; $Main = $_POST['Main'];
  3. Try this code. <?php $conn = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($databse_name,$conn); $sql="SELECT * FROM new"; $result=mysql_query($sql); $data=mysql_fetch_array($result); $gebruiker=$_SESSION['username']; if(!isset($_GET['x'])){ $aantal=4; }else{ $aantal= $_GET['x']; } ?> <html> <head> </head> <body> <h3> </h3> <fieldset class="dashboard"> <legend class="dashboard">Beheer</legend> <?php if (isset($_REQUEST['submit'])) { $name = $_POST["name"]; $description = $_POST["description"]; $path_thumbs = "upload/thumbs"; $path_big = "upload/images"; //the new width of the resized image. $img_thumb_width = 150; // in pixel //Do you want to limit the extensions of files uploaded (yes/no) $extlimit = "no"; //allowed Extensions $limitedext = array(".gif",".jpg",".png",".jpeg",".bmp"); $uploaded_images = array(); // loop through uploaded images for($i = 0; $i < count($_FILES['imgfile']['name']); $i++) { if(!empty($_FILES['imgfile']['name'][$i])) { $file_type = $_FILES['imgfile']['type'][$i]; $file_name = $_FILES['imgfile']['name'][$i]; $file_size = $_FILES['imgfile']['size'][$i]; $file_tmp = $_FILES['imgfile']['tmp_name'][$i]; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if (($extlimit == "yes") && (!in_array($ext, $limitedext))) { echo "Verkeerde extensie. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>"; exit(); } //create a random file name $rand_name = md5(time()); $rand_name = rand(0,999999999); //get the new width variable. $ThumbWidth = $img_thumb_width; switch($file_type) { case 'image/pjpeg': case 'image/jpeg': $new_img = imagecreatefromjpeg($file_tmp); break; case 'image/x-png': case 'image/png': $new_img = imagecreatefrompng($file_tmp); break; case 'image/gif': $new_img = imagecreatefromgif($file_tmp); break; } //list width and height and keep height ratio. list($width, $height) = getimagesize($file_tmp); $imgratio = $width/$height; if ($imgratio>1) { $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; } else { $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //function for resize image. if (function_exists(imagecreatetruecolor)) { $resized_img = imagecreatetruecolor($newwidth,$newheight); } else { die("Error: Please make sure you have GD library ver 2+"); } imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //save image thumbnail ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); // upload original file move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext"); // add image thumbnail to array $uploaded_images[] = $rand_name.$file_ext; } } // check that there are thumbnails in uploaded_images if(!empty($uploaded_images)) { // now we insert the uploaded thumnail to database $sql = "INSERT INTO new (Main_Image, Image_2, Image_3, Image_4, Image_5) VALUES ('$Main', '$uploaded_images[0]','$uploaded_images[1]','$uploaded_images[2]','$uploaded_images[3]')"; if( ($result = mysql_query($sql)) ) { echo '<p><img src="images/icons/accept.gif" alt"" /> uploaded!</p>'; $page = "index.php?page=portfolio"; $sec = "1"; //header("Refresh: $sec; url=$page"); } else { echo "ERROR: ".mysql_error(); } } } else { ?> <div id="container"> <form action="" enctype="multipart/form-data" method="post" class="niceform" name="UD"> <dl> <dd> <?php for($i=0; $i < $aantal; $i++) { ?> </dd> </dl> <dl> <dt><label for="imgfile">Kies foto:</label></dt> <dd><input name="imgfile[]" id="imgfile[]" type="file" /> <input type="checkbox" name="Main" id="Main"> <label for="Main"></label></dd> </dl> <?php } ?> <dd><input type="submit" name="submit" id="submit" value="Insert" /></dd> </form> </div> </fieldset> <?php } ?>
  4. I dont understand that. Can you explain it more clearly.
  5. Its doing exactly what you are telling it to do. You are inserting 4 duplicate entries, for Image_2,Image_3,Image_4, and Image_5 mysql_query("INSERT INTO new (Main_Image,Image_2,Image_3,Image_4,Image_5) VALUES ('$Main','$rand_name.$file_ext','$rand_name.$file_ext','$rand_name.$file_ext','$rand_name.$file_ext')"); What are tying do? What should the code do?
  6. Sorry I had a typo. My code should of been echo ' <option value="1"' . (($WHSTATUS == 1) ? ' selected="selected"' : '') . '>Active</option>'; echo ' <option value="0"' . (($WHSTATUS == 0) ? ' selected="selected"' : '') . '>In-Active</option>';
  7. Also this is incorrect syntax echo ' <option value="1"' <?php if($WHSTATUS == 1) ? 'selected="selected">';?>' echo '>Active</option>'; echo ' <option value="0"' <?php if($WHSTATUS == 0) ? 'selected="selected">';?>' echo '>In-Active</option>'; It should be echo ' <option value="1"' . (($WHSTATUS == 1) ? ' selected="selected"' ? '') . '>Active</option>'; echo ' <option value="0"' . (($WHSTATUS == 0) ? ' selected="selected"' ? '') . '>In-Active</option>';
  8. Line 23 in header should be if(isset($_SESSION['signed_in']))
  9. have you read this page http://uk3.php.net/session_start It explains and shows clearly how and where you call this function (look at the examples).
  10. its the line of code I posted in reply #3 To include the name in the email mail("tamir@tamirt.co.il", 'site email: '.$subject, $_SERVER['REMOTE_ADDR']."\n\nname: $name\n\n$message", "From: $from");
  11. Oh didn't read your post properly. I though $row['cat'] echos a category each time. $categoroes = explode(',', $line['cat']); foreach($categories as $k => $category) { $categories[$k] = '<a href="category.php?id='.$category.'">'.$category.'</a>'; } echo implode(', ', $categories);
  12. echo '<a href="category.php?id='.$line['cat'].'">'.$line['cat'].'</a>';
  13. One way would be preg_match if(peg_match('#/articles/\d+/?#', $requestURI) { // do something } The above should match /articles/1 or /articles/102356 But if your using mod_rewrite then just check if the page id exists (refer to requinix example) if(isset($_GET['id'])) { // do something }
  14. Also you're trying to update/delete records where Name = $_POST['hidden']. The form field named hidden is set to the records ID not the Name echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></td>'; You need to change your update/delete queries where clause to WHERE ID = $_POST['hidden']
  15. This Means the http server encountered an error trying to run error.php Check Apaches error logs for why you are getting that error (I think the error log is located in C:\XAMPP\Apache\logs\error.log). Look at the last line for most recent error messages. What is the error?
  16. No idea but try if ($result = $mysqli->query("SELECT p.pid, p.firstname, p.lastname, c.Nickname FROM dRplayer p, dRcontract c WHERE c.pid = p.pid "))
  17. Check that the query returned an results, if there are results display table, else display message if(($num_rows1 = mysql_num_rows($result1)) > 0) { $x = 0; $num_cols = 4; echo " <table cellpadding='0' cellspacing='0' border='0' width='100%'> <tr> <td valign='top' width='25%'>"; while($row = mysql_fetch_array($result1)) { if ($row['name1'] == $row['title'] && $row['besteld'] == '0') { echo "<a href='../".$row['path']."/".$row['id']."-".$row['alias']."'>".$row['name1']."</a><p />"; } else { echo ""; } $x++; if ($x == ceil($num_rows1 / $num_cols)) { echo " </td> <td valign='top' width='25%'>"; $x = 0; } } echo " </td> </tr> </table>"; } else { // display no planes found message }
  18. Sorry I meant to say display_errors is off. If error_reporting is off then no errors will be logged. The E_USER_* error constants are used for reporting your own custom errors when using trigger_error. Again anything to do with errors and how to handle them is explained in the manual which gristoi linked to.
  19. Post your full code
  20. In the form code I changed the field names to all lowercase, to get the name use $_POST['name'] for address use $_POST['address']. Are you using my code as it is in reply #4?
  21. The bind values for the $StartDate and $EndDate, I think need to be s not i // bind params for update $stmt->bind_param("iisssii", $pid, $tid, $Nickname, $StartDate, $EndDate, $PlayerSalary, $id); // bind params for new record $stmt->bind_param("iisssi", $pid, $tid,$Nickname, $StartDate, $EndDate, $PlayerSalary);
  22. You'll need to use curl to send data via post. Data passed in the url will always be sent via GET To properly targer all links you need to do as .josh suggest.
  23. Did you copy and paste my code correctly? I have copied and pasted it and I get no syntax errors for line 33 echo '<td><input type="text" name="name" value="' . $record['Name'] . '" /></td>';
  24. Change if(empty(field('a3'))) to if(field('a3') == '')
  25. Question1 For some reason your host has this directive defined twice. All errors is logged to the file named error_log Question 2 If error reporting is off, then yes all errors will be logged. What types of errors are logged depends on the level you have set error_reporting to. Setting error reporting to E_ALL & ~E_NOTICE will log all errors except notices Question 3 No
×
×
  • 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.