Jump to content

ethan89

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Everything posted by ethan89

  1. Thanks! It works perfectly! I removed the number of directories parts of the code and made it shorter. Here is my final code: <?php $path = '.'; $no = "0"; if ($handle = opendir($path)) { while (false !== ($img = readdir($handle))) { if ($img != "." && $img != ".." && $img != "index.php") { $img = $path.'/'.$img; if (is_file($img)) $no++; } } closedir($handle); } echo "$no"; ?> SOLVED, Thanks phobic
  2. At first I thought you code worked, but it displays 1 every time.
  3. I've tried this code and a few others, but it only displays 0. I'd like the simplest working way to display the number of files in a directory. Thanks for the help! $directory = "../images/team/harry/"; $filecount = count(glob("" . $directory . "*.*")); echo $filecount;
  4. Sorry, but I said I don't have a database.
  5. I see several great PHP/MySQL paging systems on google, but how can I make a paging system when I'm just showing all images in a directory, not showing all images from a database? I have no idea how I could convert one of those mysql systems to work for my needs. Here is my code: <?php $columns = "4"; $count = "0"; echo '<div style="overflow:auto; width:500px; height:266px;"><table cellpadding="0" cellspacing="10">'; if ($handle = opendir('.')) { while (false !== ($image = readdir($handle))) { if ($image != "." && $image != ".." && $image != "index.php") { if (strlen($image) > 11) { $short = substr($image,0,11); echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$short.'...</div></a></td>'; } else { echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$image.'</div></a></td>'; } $count++; if ($count == 4) { echo "</tr><tr>"; $count = 0; } } } closedir($handle); } echo "</table></div>"; ?> This code shows all images in a directory, 4 per row. I'd really appreciate some help with adding a paging feature to this. Thank you so much for the help!
  6. No prob. I'm glad you made this topic, or I would have never gotten it done myself.
  7. Never mind, I was able to edit it. I made it short and simple: <?php if (strlen($words) > 10) { $short = substr($words,0,10); echo ''.$short.'...'; // This will display 10 letters and ... (Textistool...) } else { echo 'The text that isn't too long goes here'; } ?> As you can see, it's easy to change how long you want the text to be before the ... I did notice one problem with using this code though. If one of your columns has 10 W's (WWWWWWWWWW), it's much longer than 10 a's (aaaaaaaaaa), so it still may go over to the next line . It's not a huge problem I guess. To fix this problem, I use this before the text: <div style="overflow:auto; width:100px;">TEXT HERE</div> Make it the width of your column, and those W's will just be cut off instead of go to the next line, but you won't be able to see the "..." because it will be cut off too..
  8. Since you've created this topic, I'm really interested in adding this to my site as well. I found this code online. It appears to be exactly what we're looking for, but it needs to be edited some: <?php $file = "Hellothisfilehasmorethan30charactersandthisfayl.exe"; function funclongwords($file) { if (strlen($file) > 30) { $vartypesf = strrchr($file,"."); $vartypesf_len = strlen($vartypesf); $word_l_w = substr($file,0,15); $word_r_w = substr($file,-15); $word_r_a = substr($word_r_w,0,-$vartypesf_len); return $word_l_w."...".$word_r_a.$vartypesf; } else return $file; } ?> One problem with this code is that it puts the "..." in the middle of the words, which is good if you want to see the beginning and end of the line, but I want the "..." at the end of the words. Will you do me a favor and give me your edited version if it works for you? I'm not that good at PHP
  9. Thanks for your help, Abra. It turns out all I needed to do was change http://www.EXAMPLE.com/users/member.php to ../member.php. I love it when there is such a simple solution to a seemingly huge problem
  10. Oh.. I put member.php in the same folder as index.php just to test that it works and it does. I guess the http:// was messing it up like you said. I have a problem though. I can't put member.php in the same folder as index.php later. How can I include member.php in index.php without using http://www if it's one folder back? :-\
  11. I tried doing user/member.php and /user/member.php and it can never find the directory so I had to do the whole URL. Do you think this is my problem? Maybe it's not possible to do it without the whole URL since member.php is in users/ and index.php is in users/*username*/ I defined $member in index.php
  12. I've had this problem too. What I do is put this around the text: <div style="overflow:auto; width:100px;">text goes here</div>. You have to set the width to the same width as your column though. The problem is, this doesn't add the "..." that you want.
  13. included in index.php? I hope that wasn't confusing. Here is my complete problem: I have one page called index.php that contains: <?php $member = substr(dirname($_SERVER['PHP_SELF']), ; // This is the name of the directory include 'http://www.EXAMPLE.com/users/member.php'… ?> I have another page called member.php (the one that is included) that contains: <?php echo "$member"; ?> There is only one problem. The above code doesn't work. It won't display $member. How can I fix this? Setting a cookie didn't work. Maybe because member.php is included in index.php and I'm not going from index.php to member.php. Thank you very much for the help! I appreciate people taking their time to help other people.
  14. Oh never mind, it works perfectly. I was doing something wrong when I tested it last time. Thanks so much guys. Solved
  15. I thought about hashing but it seems complicated, because then I have to add a reset password thing instead of just sending them their password.
  16. Well, it's a big improvement that it doesn't show the info in the URL anymore, but instead of changing the password or making the password blank, now it just doesn't do anything and the password stays the same.. Maybe I can solve this on my own now that it's not hugely messed up anymore, but it would be cool if someone could tell me what's wrong . I will mark this as solved as soon as it's fixed.
  17. Ohhhhhhhhhhhhhhhhhhh I was really concerned about the password being displayed at the top lol. Thanks for searching through my garbage code and finding my silly mistake! I really don't think I could ever spot that on my own . Thanks so much for helping me! I'll post again to tell you if it changes the password or not
  18. Sure, I can do that, but I just realized that I gave you the wrong code. That's the second time today. I don't know what is wrong with me. Here it is: <form action="change_email.php"> Current Email: <input type="text" name="email"> New Email: <input type="text" name="newemail"> Confirm New Email: <input type="text" name="confirmnewemail"> <input type="submit" value="Change Email"> </form>
  19. Sure, thanks for helping me out. <?php session_start(); if(!isset($_SESSION['username']) || (trim($_SESSION['username'])=='')) { header("location: members_only_area.php"); exit(); } ?> <form action="change_password22.php"> password<input type="password" name="password"> new password<input type="password" name="newpassword"> confirm new password<input type="password" name="confirmnewpassword"> <input type="submit" value="Change Password"> </form>
  20. I don't understand anything you said. I'm a complete newbie at PHP. I haven't had anything go wrong before when getting something using $_POST.
  21. newemail is what the person puts into the form. The form didn't have any empty fields when I tried it.
  22. I can give you a very simple working one. It may help you out: The form: <form action="sendmail.php"> Name: <input name="name" type="text"><br> Message: <input name="message" type="text"><br> <input type="submit" value="Send"> </form> The script: <?php $name = $_REQUEST['name'] ; $message = $_REQUEST['message'] ; mail( "YOUREMAIL", "THESUBJECT", $message, "From: $name" ); header( "Location: FORWARDURLGOESHERE" ); ?>
  23. This is completely different code than my change password script thread. This is not double posting. Whenever I use this script to change my email, it just changes the email to nothing (blank). What could be wrong with it? Help is hugely appreciated. I know you don't have to use your valuable time to help me. <?php // I removed the connect to db part session_start(); $username = $_SESSION['username']; $email = $_POST['email']; $newemail = $_POST['newemail']; $confirmnewemail = $_POST['confirmnewemail']; $result = mysql_query("SELECT email FROM members WHERE username='$username'"); if($email!= mysql_result($result, 0)) { echo "The email address you entered is incorrect."; } if($newemail==$confirmnewemail) $sql=mysql_query("UPDATE members SET email='$newemail' where username='$username'"); if($sql) { echo "You have successfully changed your email address."; } else { echo "The new email and confirm new email fields were different."; } ?>
×
×
  • 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.