Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. It was explained pretty well by PFMaBiSmAd on that link.. The reason why on the 3rd page you're not getting the data is because it's only posted directly to that 2nd file, if you want to have to available later on I'd use a session Example: 1st: name="field" 2nd: session_start(); $field = $_POST['field']; $_SESSION['field'] = $field; 3rd: session_start(); $showfield = $_SESSION['field']; echo $showfield;
  2. That's interesting. It's cool to see different takes on the problem. I could make mine shorter, but I added some protection (for example support if there's more than one delimiter), but I noticed that's stupid because there would be other problems with my code if there was one more than one. And if it was just a decimal (as the OP noted) then there would be no need to have more than one. So removing the pointless stuff, and changing it a bit, I came up with this: $str = '1011101.1011'; $split = str_split($str); $str = str_pad($str, 3 - array_search('.', $split) % 3 + strlen($str), "0", STR_PAD_LEFT); $str = str_pad($str, 3 - ((count($split) - 1) - array_search('.', $split)) % 3 + strlen($str), "0", STR_PAD_RIGHT); $split = str_split($str); for($i = 0;$i < count($split);$i++) if($split[$i] == '.') $split[$i] = ' . '; else if($i % 4 == 0) array_splice($split, $i, 0, ' '); echo implode($split); @KingPhilip: Thanks, never knew about str_pad Edit: Oh I guess it did need support for without a decimal. Oh well, no time to edit it now, going to bed, was fun.
  3. I'm about to head off to bed in a little bit (After I finish working on something..) But if you want I'll break it down and explain it part by part.
  4. That shouldn't cause a difference because there's only 1 expression being evaluated there.
  5. True, mine doesn't account for that. GG. One small tip though, you don't need to create a string containing a-z then using strpos(), you can just use ctype_alpha() Edit: Accounting for what RussellReal pointed out, here's my new version: $str = '.l.o.r.e.m.i.p.s.u.m'; for($i = 0, $cap = true;$i < strlen($str);$i++) { if(!ctype_alpha($str{$i})) continue; $str{$i} = ($cap) ? strtoupper($str{$i}) : $str{$i}; $cap = !$cap; } echo $str;
  6. Hm, I came up with something myself.. Edit: Fixed it. <?php $str = '1011101.1011'; $split = str_split($str); $num_len = count($split) - cc('.', $split); $num_before = array_search('.', $split); $num_after = $num_len - $num_before; if($num_before % 3 != 0) $str = implode(array_fill(0, 3 - $num_before % 3, 0)) . $str; if($num_after % 3 != 0) $str .= implode(array_fill(0, 3 - $num_after % 3, 0)); $split = str_split($str); for($i = 0;$i < count($split);$i++) if($split[$i] == '.') $split[$i] = ' . '; else if($i % 4 == 0) array_splice($split, $i, 0, ' '); echo implode($split); function cc($char, $arr) { $num = 0; foreach($arr as $part) if($part == $char) $num++; return $num; } ?>
  7. Lol, I'm an idiot. Just realized it could've been done like this also: <?php $str = 'loremipsum'; for($i = 0;$i < strlen($str);$i+=2) $str{$i} = strtoupper($str{$i}); echo $str; ?>
  8. mine DOES work.. its tested (by me) to work, also, yours looks better so he should stick with yours imo Just don't talk about my code if you haven't tried it. Thanx I did try it, but I tried it before you edited it, so that's why it does work. After you edited it to fix it, it does work. I believe the only problem was that at the end you were echoing the wrong variable.
  9. Np Just remember to press the "Topic Solved" button on the bottom left.
  10. Do I echo the jquery script part?? for example echo '<table class=zebra">'; echo '<script type="text/javascript" src="js/jquery-1.3.2.min.js">$(document).ready(function() { $(".zebra tr:even").addClass("alt"); });</script>'; You could, but it would be a better idea to put that script inside of your header. And Woah, just noticed a stupid mistake.. You should have something like this in your header: <head> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script language="javascript"> $(document).ready(function() { $(".zebra tr:even").addClass("alt"); }); </script> </head> Edit: Also make sure that you actually have the jQuery library loaded and in the correct location..
  11. Your problem is a configuration setting in php.ini; you need to change sql.safe_mode = ON to OFF.
  12. Forget about my method, use the jQuery that you were originally using. Give your table a class name, eg: <table class="someClass"> then in your jQuery: $(".someClass tr:even").addClass("alt");
  13. Actually taking a look at it this time it's pretty clear what it does if you have a brief understanding of jQuery. You would know that $() is a selector. So $(".thead tr:even").addClass("alt"); basically means it takes all of the tr children of the thread elements that are even and add a class called alt to those elements.
  14. Putting code that contains php between [ php ] tags rather than [ code ] is a better idea because the syntax highlighting makes it easier to read.
  15. $end errors are generally caused by either missing or extra brackets ({, }). I popped your code into Notepad++ really fast and saw that the bracket on this line: if (!@mysqli_select_db($DBConnect, $DBName)) { isn't being closed anywhere.
  16. It would be nice if you were a little more specific, and if you showed us the array of images, would be easier for us to tell you how to set it up. Right away though, I see this: $currentImage = "images//" . substr(strrchr($row['Path'],92),1); Is that supposed to be images/ with only 1 '/'?
  17. I'm not specifically familiar with that jQuery function, but here's the way that I would do it: echo '<table>'; echo '<thead><tr><th><U>Name</U></th><th><U>Name2</U></th><th><U>Name3</U></th><th><U>Name4</U></th><th><U>Name5</U></th><th><U>Name6</U></th></tr></thead>'; $i = 0; while ($row = mysqli_fetch_array($data)) { $class = ($i % 2) ? "class='alt'" : NULL; echo '<thead><tr ' . $class . '><td><strong>' . $row['name'] . '</strong></td>'; echo '<td>' . $row['name2'] . '</td>'; echo '<td>' . $row['name3'] . '</td>'; echo '<td>' . $row['name4'] . '</td>'; echo '<td>' . $row['name5'] . '</td>'; echo '<td>' . $row['name6'] . '</td>'; echo '</td></tr></thead>'; } echo '</table>';
  18. if(isset($_POST['submit'])) echo implode($_POST['number']); echo "<form method='POST'>"; $numbers = range(0, 9); ob_start(); echo "<select name='number[]'>"; foreach($numbers as $number) echo "<option value='$number'>$number</option>"; echo "</select>"; $ele = ob_get_contents(); echo $ele, $ele, $ele, "<br /><br /><input type='submit' name='submit' value='Send!'></form>";
  19. Can you be a little more specific about exactly what's not working? Edit: One thing I see straight off the bat is that $data isn't even defined, or did you just not copy and paste the whole thing?
  20. I'm not sure what you mean.. Previously this: if($match[1]) $fsize=mysql_real_escape_string(strip_tags($match[1])); was setting $fsize to something like | 104857 KB, right?
  21. Change if($match[1]) $fsize=mysql_real_escape_string(strip_tags($match[1])); to if($match[1]) $fsize= substr(mysql_real_escape_string(strip_tags($match[1])), 2);
  22. Am I missing something? Because you posted this: $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } (!$validationOK) would never validate to true.. Because all you do is set $validationOK to true then do nothing else regarding that variable. I also just realized your $Email variable is already set to $_POST['Email']. Maybe it would be best if you post your form.
  23. Assuming that every time you have just a | and a space before the file size you can use substr() eg. $str = '| 104857 KB'; echo substr($str, 2); // "104857 KB"
  24. Sorry if I confused you Assmusing that the name property of the input element that you want to enter the email address into is "Email" (Case matters), just make $EmailTo = $_POST['Email'];
  25. You use the $_POST super-global. eg. $_POST['Email']; Also, just a few tips relating to your code. echo is generally better to use over print because it's faster. Another small thing is it's a better idea to use the Location option for header() over a meta refresh. eg. header('Location: error.html'); exit;
×
×
  • 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.