Jump to content

wrathican

Members
  • Posts

    446
  • Joined

  • Last visited

    Never

Everything posted by wrathican

  1. or you can use the nl2br() function. it converts the 'new lines' in a text area/php posted string in line breks so they can be displayed in html
  2. oh no problems. i just tried the sql (modified to meet my needs of course) and i got an error. it said unknown column Index. but this would probably be the best way so far.
  3. well, i have already sort of started work on the gallery. and plus i like the experience. like you guessed the image id in the url is based on the id of the image stored in a DB. the ID the an auto inc. int. but the thing is there might be 50 images belonging to 5 different albums and not all of the 10 images will be next to each other. so the id's of the images belonging to album 3 could go 23,24,25,27,30,37,42,43,50 i guess i would do something like this: <?php $albId = $_GET['albid']; $imgId = $_GET['picid']; //query $query = "SELECT * FROM table WHERE table_albumid='".$albId."'"; // selects all images belonging to the album $result = mysql_query($query); //queries the db while ($row = mysql_fetch_array($result)) { //start a loop? //and then this is where i get stumped. //i imagine i would use an if statement to see if the current image id matches $imgId //then work out which ones are next //but how do i work out the previous? } ?>
  4. page refresh isnt a problem. but thanks for the help. this is how i thought i might have to do it.
  5. if you were to do the header and footer includes around the content, how would you link to sub folders and directories? would you use the PHP_SELF? or something to the like?
  6. Hey, Thanks for looking. Im having a bit of a problem. Im making a website for a photographer and I showed him a design and a way for him show off his work. The design can be seen here: www.ls12style.co.uk/projects/Wonstar/gallery.php?func=viewal&alid=1 The problem i'm having is that when it comes to displaying the 5 thumbnails at the bottom, i don't know what to do. I mean i can everything from a database no problem but i think what i need is a bit of pagination. what i want to happen is the image in the middle be the current image that is on display and the two images to the left and to the right is that these are the next/previous two images. as you can see from the link, the id of the image to be displayed is taken from the URL. i also want a next and previous button that shows the next image in the 'film strip'. any ideas how i can do this? Thanks in advanced
  7. you need to tell php to output the variable instead of the string. what your doing is telling php the echo $nick. that being the actualt bit that you typed. that you need to do is concetenate the string. like so echo 'blahh ' . $nick . ' blahh.';
  8. hey the site is quite nice. although i did see one bug. on the 'Eligible properties' part on the home page the 'more information' link is lower than the container of the text. so the border 'strikes through' the link. other than that spot on mate.
  9. hey people. i have very limited knowledge of JS and what i have at the moment is an image upload form. i want to change this single image upload to a multiple image upload. in the form i have three 'box's'. i have a text input, file input and a textarea. the two inputs cannot be empty but the textarea can be. what i want to happen is that when the file input has been filled and the other input i want another set of these three 'box's' to be displayed. but i only want this to happen a maximum of five times so only five files are to be uploaded. i can check the form once but then i have no idea what to do/how to it next. so far i have gotten this far: function displayFields() { var name=form.name.value; var file=form.pic.value if ((name!="") && (file!="")) //i guess i show the extra fields here? } </script>
  10. ah i see about the infinate thing: would: while(!empty($_FILES['file'])) work?
  11. what exactly in my loop didn't make sense? i thought it made perfect sense i know i didnt move the ['tmp_name'] and maybe i missed out some ';' but i thought that would have worked otherwise
  12. well, thanks for the advice. i just wanted to know whether or not i had to set the ini options at the beginning of my script. i feel better not having to since im not my host. so is it best practice to do it the way you recommended rhodesa? is a while a bad idea?
  13. hey guys im thinking of creating an upload form for my users that can handle multiple files. What i want to happen is there be one file input to begin with. when that input has a file selected display another one. i am aware that is done using javascript. What i want from this forum is a few answers. If the user selects 5 files to be uploaded and each file is 512Kb big then the TOTAL file size of all the files together would be 2.5Mb. If the PHP upload limit is 2Mb would this cause the script to fail? Or does it count each file selected as an individual file? Can I use a while loop to process the upload? e.g: <?php $file = $_FILES['file']; $dest = "some/folder/"; //i realize i need to get the name but this is a quick example. $i = 1 while(!empty($file)){ //process upload $upload = move_uploaded_file($file, $dest); if($upload) { echo "File " . $i . " has been uploaded"; }else{ echo "File " . $i . " has not been uploaded"; } $i++; } ?>
  14. is there a way to check if flash player is installed on a users machine using PHP?
  15. hey people I have made a forum and im using the nl2br() function so a user can enter things on new lines and they appear that way. what i need is a function to remove each instance of <br /> when it comes to editing the post. any help?
  16. well, ive looked at pagination but it cant see how to implement this to suit my needs. i couldnt use the LIMIT clause because i only want to display one image. so i need to find out the ID of the next image in the album and the previous image the album. these may not be in order so the current image ID could be 34 and the next image could be 55 that belongs to that album and previous image could be 6. i kinda figure it would happen something like this: GET current image id from url GET current album id from url QUERY the database an select all the images that belong to the album do some sort of while loop to figure out the next an previous image id's anyone able to help?
  17. MD5 is a way of encrypting a string. personally i would use SHA1 hashing because its more secure. in relation to the actual topic: tech, the user does not need to remember the hashed password as long as you hash the password they post from the form. //user registers so first you would generate a password encrypt it store in db pass gets sent to the user //when a user logs in post the password to the login script hash it retrieve the password from the db compare the db pass and hashed posted password set session if they match to enable the user to change their password all you need to do is perform a mysql update query it is advisable for the change password form to contain three password boxes, current pass, new pass, confirm new pass. //to change a password user submits the form hash the old password check the pass against db pass check both new passwords match hash the new password update the database good luck
  18. Hey guys i am thinking of setting up my own web server at home. i have an old pc that i dont use which i plan on turning into the server. what kinda specs does a server need to have? 64bit or 32bit? linux or windows? if linux, which distribution? i want to host my own video/image hosting website - nothing huge like youtube/photobucket just a small time site for me and my friends. (max of 30 users(assume all are watching/uploading videos that need converting to FLV's)) what kinda specs does my net connection need to have? this is what my ISP's service has: Up to 8Mb download speeds Up to 400Kb upload speed 40GB monthly usage allowance are they good enough or should my own server be a no go? All advice would be fantastic.
  19. instead of update why dont you just create a new record of banned IP's in an IP table? then you still have both ip's the user is using
  20. sorry to say but that is completely wrong. there is not such 'variable' html tag Read this, it will give you a good understanding of what is going on in the post by jamesnes http://www.w3schools.com/PHP/php_get.asp
  21. YEha i have php and mysql for dummies and the manual but for this type of project i could not find what I was looking for with the resources I had so I figured I would scratch the pros' brains. Thanks for all the help by the way guys! good book, its what i used to start me off. it gives you a good idea on member systems and databases i thought. try the example aplications. (the pet store?)
  22. ive created a simple image gallery: the user can upload an image and the script will create a thubnail and add it to the DB a user recently complained to me that he gets this error: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 2592 bytes) in /home/fhlinux162/m/members.ls12style.co.uk/user/htdocs/includes/functions.php on line 146 it seems that is is just this user that gets this error. i asked him to mail me one of the images he was trying to use so i could try it. i got the same error it seems as though the GD functions do not recognise the image as a propper image and the script just fails. heres the function that handles the thumbnail creation: <?php function createThumb($result, $picWidth, $imgDir) { $poo = array(); if ($result == false) { //file could not be uploaded $poo[0] = false; $poo[1] = 1; return $poo; }else{ //file was uploaded. create thumbnail //pathinfo $file = pathinfo($result); //find the .ext $ext = $file['extension']; //strip .ext to lower $ext = strtolower($ext); //get image sizes $sizes = getimagesize($result); //ratio $ratio = $sizes[0]/$sizes[1]; //create new height $newHeight = round($picWidth/$ratio); //create true colour image $srcImg = imagecreatetruecolor($picWidth, $newHeight); if($ext == 'jpg' || $ext == 'jpeg') { $tmpImg = imagecreatefromjpeg($result); }elseif($ext == 'png') { $tmpImg = imagecreatefrompng($result); }elseif($ext == 'gif') { $tmpImg = imagecreatefromgif($result); }else{ $poo[0] = false; $poo[1] = 2; return $poo; } //create destination image filename //get filename $name = $file['basename']; //dest filename $dstFile = $imgDir . $name; imagecopyresampled($srcImg, $tmpImg, 0, 0, 0, 0, $picWidth, $newHeight, $sizes[0], $sizes[1]); //save image if($ext == 'jpg' || $ext == 'jpeg') { imagejpeg($srcImg, $dstFile, 100); }elseif($ext == 'png') { imagepng($scrImg, $dstFile, 100); }elseif($ext == 'gif') { imagegif($srcImg, $dstFile, 100); }else{ $poo[0] = false; $poo[1] = 3; return $poo;; } $killSrc = imagedestroy($srcImg); $killTmp = imagedestroy($tmpImg); if($killSrc != false && $killTmp != false){ $killOld = unlink($result); if($killOld != false){ return $name; }else{ $poo[0] = false; $poo[1] = 4; return $poo; } }else{ $poo[0] = false; $poo[1] = 5; return $poo; } } } ?> any suggestions are welcome
  23. heres my file upload function: <?php function uploadFile ($oldFile, $userFile, $imgDir) { //extensions array $validExt = array ('.jpg', '.jpeg', '.png', '.gif'); //get the file ext $ext = strrchr($userFile, "."); $ext = strtolower($ext); //check the file ext against the array if(in_array($ext, $validExt)) { //needle is in haystack //process upload //rename the file $newName = md5(rand() * time()) . $ext; //new file dest $destFile = $imgDir . $newName; //move the file to tmpDir $result = move_uploaded_file($oldFile, $destFile); if($result == false) { //there was an error uploading return false; }else{ //file was uploaded chmod($destFile, 0777); return $destFile; } }else{ //needle is not in haystack. exit return false; } } ?> this takes a file from a form and uploads it to the dir. of your choice. the function also creates a random filename, still using the pre-existing ext. so gives something like: jh4g5hjg34jh5bjh34bhjb34jh3poi345g345.doc the $oldFile is the name of the tmp file where your server stores files to upload. $userFile is the name of the file that the user selected $imgDir is the location you want to upload the file to in relation to the location of where this function is used. so, you use it in your web root and you want your file to be upload to root/uploads/word/user/ then you would us: $dir = "uploads/word/user/"; and call the function like so: <?php $tmpFile = $_POST['file']['tmp_name']; $userFile = $_POST['file']['name']; $dir = "uploads/word/user/"; $upload = uploadFile($tmpFile, $userFile, $dir); if ($upload == false) { echo "There was a problem uploading the file."; }else{ echo "The file was uploaded and renamed to : ".$upload."."; } ?>
  24. hey thanks for looking. ive created a custom image gallery and there are 3 stages. 1. view list of albums 2. view list of images within selected album 3. view selected image from select album with links to the next and previous image in the list the problem is i have no idea how to implement the next/prev links im using the $_GET method to determine which image should be displayed for stage 3. so it looks something like this: <?php $img = $_GET['img']; $query = "select * from image_table where image_id='".$img."'"; $result = mysql_query($query); ?> i thought about using a while loop to loop through each entry that belongs to the selected album and create variables numbered accordingly so it'd be something like: <?php $i = 1; while ($row = mysql_fetch_array($result) { //delclare vars $var . $i = $row['entry']; } ?> Would something like this be right? or am i going about this all wrong?
×
×
  • 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.