Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. @OP: Typically, using $_SERVER['REMOTE_ADDR'] will give you the correct IP. <?php echo $_SERVER['REMOTE_ADDR']; ?> That'd show your IP when you visit. Printf was talking about how it can be spoofed, hidden, etc.
  2. Wow, that's some hard to read code, especially since I have no clue what most of it does (i.e. $data['hm'], $data['fm']...) One thing, find: $_SESSION['status'] = $status; Add the line below: print_r($_SESSION); Make sure the other pages have the session_start(); at the top, and always use long tags (<?php) not short tags (<?)
  3. How do you have the images named?
  4. You can use mysql's encode/decode http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html edit: by encode/decode, I should've mentioned to use AES - more secure.
  5. You can't. md5 is a one-way encryption.
  6. Look at your browser's source code when you view the page. What do you see? You should see: <img src="http://localhost/test/thumbs/t-blank.gif" border="0"> That's what I see when I run the code. I'm thinking maybe your wanting to check to see if the file exists, and not if the variable is empty?
  7. Pretty much, it simplified the random process & will allow for easier expansion (and prevents the error you originally had - missing one of the captions/urls). The only thing it doesn't do is show the image, but that's just because of the difference in ways I would do the sponsor image (I'd use their name, instead of a number) If you wanted yours to work, pretty much just put: <tr> <td align="center"><img src="images/random/<?php echo $randoms.".jpg" ?>" height="25" /></td> </tr> <tr> <td align="center"><a href="<?php echo $img ?>" class="link"><?php echo $caps ?></a></td> </tr> Inside the loop: for ( $i = 0; $i < 3; $i++){ $caps = $captions[$randoms[$i]];; $img = $urls[$randoms[$i]]; }
  8. <img src="http://localhost/test/thumbs/t-<?php if(!isset($url) || empty($url)) echo 'blank'; else echo $url; ?>.gif" border="0"> What does the source show?
  9. The reason it wasn't working, is because you're calling $caps, $img, $randoms outside the loop, so it'll just show the last element. for ( $i = 0; $i < 3; $i++){ $caps = $captions[$randoms[$i]];; $img = $urls[$randoms[$i]]; } I could set $caps equal to 5, then 3, and finally 2. However, when you call the variable outside the loop, the only one that you can see is 2 since you overwrote the others. I played around with your code a bit. It won't work to your full intents, i.e. there is no dashed line, and you'd have to rename your images probably. Nonetheless, it'd be a lot easier to expand your list later on: <?php // Create image array $imageArray = array( 'RBC' => 'http://www.royalbank.com', 'Prodomax' => 'http://prodomax.com/', 'Liews Motors' => 'http://www.lewismotorsinc.com/', 'Advanced Motion Controls' => 'http://a-m-c.com/', 'Burnside' => 'http://www.rjburnside.com/', 'TD Canada Trust' => 'http://tdcanadatrust.com', 'Reinhart' => 'http://www.reinhartfoods.com/', 'SCDSB' => 'http://www.scdsb.on.ca/', 'ARO' => 'http://www.aronet.com/', 'Stayner Lions' => 'http://www.lionsclubs.org/', 'test' => 'test', 'ComTek' => 'http://www.comtekcomputers.com/', ); // Select a few items $imageRand = array_rand($imageArray, 3); // Run the loop foreach($imageRand as $name) { echo '<tr><td align="center"><a href="',$imageArray[$name],'" class="link">',$name,'</a></td></tr>'; ?> By the way, with the code you gave, there were several minor things wrong with it. "$caps = $captions[$randoms[$i]];;" - double semicolons, your table code isn't lining up (I had a hard time finding the matching opening closing cell & row tags), yeah... Anyways, feel free to play around with what I gave you.
  10. Err, I misread the question. premiso is correct. If that is your page though, use $_GET['lot'] to get the number
  11. If you echo that out you should see something like: Do you really want that ' . in front of the value?
  12. What does your code look like?
  13. Are you reading anything we are putting out in front of you? Your code... if (trim($_POST['psswrd']) != trim($_POST['repsswrd']) && (strlen(trim($_POST['psswrd']))>=4 && strlen(trim($_POST['repsswrd']))>=4)) ... reads: If the passwords are not equal AND the length of both passwords are greater than 4, throw an error. Also, you don't need to check both passwords for length - it's a waste of resources. If the passwords match, they'll have the same length. If they don't match, you're already throwing an error, so the user will have to re-enter a password anyways. In plain English, type out what are you trying to do.
  14. Uhh, that doesn't really help Here's what I would suggest, and trust me, it will help you not only here but in the future as well. Go through your code, using an editor with a syntax highlighter (you probably already are.) Comment and indent your code properly. There are a lot of mysql queries, that I don't really have a clue on what they are doing, lol. Example, and I'm just guessing: // Get replies: $qry = mysql_query("SELECT * FROM `mainreplys` WHERE `topicid` = '$topicid' AND `forum` = '$forum' ORDER BY `id` DESC LIMIT $forum_look , $forum_count")or die(mysql_error()); A lot of your queries could also be combined into fewer queries. Have you ever used a JOIN?
  15. Okay, in your query you have AND `Lock`='$lock', however I can't find where you are getting $lock from, AND you're setting the query result to that same variable name ($lock) Try: $lock = mysql_query("SELECT * FROM `maintopics` WHERE `id` = '$topicid' LIMIT 1")or die(mysql_error());
  16. Can you tell me what's wrong with this statement: $lock = mysql_query("SELECT * FROM `maintopics` WHERE `id` = '$topicid' AND `Lock` = '$lock' LIMIT 1")or die(mysql_error()); perhaps the variable $lock?
  17. Oh boy, your error is easy to spot: if ($lock == `locked`){ echo "<table><tr><th>Sorry This Topic is Locked to New Replies</th></table>" elseif ($lock == `unlocked`){ <p></p> echo "<form action="" method="post"> <input type="hidden" name="forum" value="<? print $forum; ?>"> <table width="45%" align="center" class="tbl"> <tr><td align="center" class="hdr">Reply</td></tr> <tr><td align="center" class="sub">Message</td></tr> <tr><td align="center" class="tbl"> <textarea name="reply_message" cols="30" rows="3"></textarea> </td></tr> <tr><td align="center" class="sub"></td></tr> <tr><td align="center" class="tbl"> <? sub(submit,"Post Reply"); ?> </td></tr> </table> </form>" } There is a lot wrong with that code, try this: if ($lock == 'locked'){ echo "<table><tr><th>Sorry This Topic is Locked to New Replies</th></table>"; // add semicolon } else { // had no echo for the <p> tags // and the quotes were not escaped. Easy solution, take the html out of PHP. ?> <p></p> <form action="" method="post"> <input type="hidden" name="forum" value="<?php echo $forum; ?>"> <table width="45%" align="center" class="tbl"> <tr><td align="center" class="hdr">Reply</td></tr> <tr><td align="center" class="sub">Message</td></tr> <tr><td align="center" class="tbl"> <textarea name="reply_message" cols="30" rows="3"></textarea> </td></tr> <tr><td align="center" class="sub"></td></tr> <tr><td align="center" class="tbl"> <?php sub(submit,"Post Reply"); ?> </td></tr> </table> </form> <?php } Also, be careful using short tags (<?). I replaced them with normal tags (<?php), but there are still some in your code. Edit: I'm looking through the rest of your code, and there are a lot of typos. $numm = mysql_numrows($chk); should be $numm = mysql_num_rows($chk);, etc. Take a look over your code again.
  18. Show more code please. Also, Enum ('Unlocked','locked') and $lock == "unlocked" can cause problems (case wise)
  19. I feel like you're not even trying to do this on your own. I have given you the separate code snippits, and explained what they are used for. I then showed you how to combine them, to what your original question was. Which I should remind you was: My code does exactly that. Now, I'll give you this pseudocode: Use the code I gave you, and try to accomplish that. Edit: correction to pseudocode.
  20. They just need to re-count the post counts in the admin area. It probably happened since the db server went down
  21. Okay, I don't think you understand your own logic. I'm going to put it with generic field names, so you will need to change the field names You want: "Passwords do not match" Thus, generically your logic statement would be: if($_POST['password1'] != $_POST['password2']) // Passwords didn't match "Password is too short, less than 4 character": if(strlen($_POST['password1'])<=4) // Password is too short Putting them together: if(($_POST['password1'] != $_POST['password2']) || (strlen($_POST['password1'])<=4)) // Password either doesn't match or is too short Now, to explain "if two variables are same they have same length." This is a correct statement. Think about it, if I type in "abcdef" and "abcdef", they are considered to be equal, correct? Thus, they will have the same length. Now, if they don't match, let's say "phil_was_here" and "hello" - they are not equal (passwords don't match), and you won't have to really worry about making sure they are the correct length (since they don't match)
  22. You need this: if((trim($_POST['psswrd']) != trim($_POST['repsswrd'])) || strlen(trim($_POST['psswrd'])) <=4)
  23. So, this reads: if (trim($_POST['psswrd']) != trim($_POST['repsswrd']) or strlen(trim($_POST['psswrd'])) >=4) If the trimmed passwords don't match or the length of the password is greater than or equal to 4...
  24. Yup, whenever you come across that, take a look at your html source code when viewing the page. You'll notice it pretty quick
×
×
  • 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.