Jump to content

Snart

Members
  • Posts

    101
  • Joined

  • Last visited

    Never

Everything posted by Snart

  1. You edited your post, you mean. Here's the code I tried: $cart = "11;5 5/8"; $var = explode(',',$cart); $cnt = count($var); for ($i=0; $i<$cnt; $i++) { list($id, $size) = explode(";", $var[$i]); if (isset($size)) { echo "ID is $id and Size is $size <br />"; } else { echo "ID is $id and there is no size! <br />"; } } The result looks fine: ID is 11 and Size is 5 5/8 If you really can't get the explode to work properly, you can str_replace(';', '', $id);
  2. Can you give me the result of echo "$cart"; ?
  3. How about adding a hidden input field and leaving the submit button just for what it's made for: submitting the form?
  4. Just checking. Sometimes you think it's displaying that, but it really isn't. Your code should be fine if $var[$i] is that number. I ran it here and it came out ok.
  5. Can you echo $var[$i] in the beginning of your for-loop?
  6. $_POST['Bin'] is an array with one element in it (the ItemID). The functions you are using strtolower(mysql_real_escape_string(stripslashes())) are string functions and will not work on an array.
  7. Have you tried with collation utf8_general_ci?
  8. Cool, I'm learning here too. I like this site.
  9. You need to call the function with an object, not with a descendancy reference: $pw = new PasswordStrength(); echo $pw->Score($password, $options, $containsWord, $words, $username);
  10. Negative unix timestamps can be created with strtotime() and stored in unsigned INTs. And an INT only takes up half as much space as a datetime.
  11. Snart

    ERD!

    http://www.smartdraw.com/tutorials/software/erd/tutorial_01.htm
  12. Formatted dates can be a huge pain in the back to work with, especially on db-level. I'd convert the date into a timestamp with mktime() and store it as an INT.
  13. Stick them in an array and check if they already exist in that array. That way, you can also sort the array afterwards if you wish, and you can concatenate the results into one big string before echoing (one big echo is faster than multiple small ones). Untested code, so may still contain errors: <?php $articlesToShow = array(); $k = 0; foreach($article_rows as $article_row) { //get the location info for each article $locations_a = explode(',', $article_row->locations); //for each location id for an article, compare against profile $i=0; foreach ($locations_a as $a) //from article { $j=0; foreach ($locations_p as $p) //from profile { if(($a == $p) && (!in_array($article_row->title, $articlesToShow))) { $articlesToShow[] = $article_row->title; } $j++; } $i++; } $k++; $arts = ''; foreach($articlesToShow as $art) { $arts .= '<li>'.$art.'</li>' } echo $arts; ?>
  14. Because the first value is attributed to "Value" due to the "Value=" in your URL. Try with echo "<script language=\"javascript\"> window.location = \"Pagination.php?$string\";</script>\n";
  15. Assuming that Last Punch is a timestamp and is kept in a MySql field called lastpunch: SELECT * FROM `emplyees` ORDER BY lastpunch DESC LIMIT 1
  16. As for 2): file() will return an array of lines within the file, but I'm pretty sure that the newline characters for each line are preserved. For example: Contents of runningclubs.txt: Club1 Club2 Club3 Then you use foreach ($lines as $line). The first iteration of $line will not be: Club1 but instead, $line will be: Club1\n or perhaps even: Club1\n\r If your clubnames do not contain \ then filter out the newline characters: if ($pclub == trim(str_replace(array('\n', '\r'), '', $line)))
  17. As for 1): This code apparently results to false: if (!$_POST["firstname"] || !preg_match("/^[a-zA-Z]+$/", $_POST["firstname"])) I wouldn't be surprised if it is the !$_POST["firstname"] part. To see if an array element exists, use array_key_exists() or at least isset() I'll take a look at 2 asap.
  18. Mysqli stands for mysql improved. It is available starting from PHP5 and Mysql 4.1.2. It offers more functionality and security through prepared statements, multi queries, ... Mysqli is generally preferred over mysql, and especially with prepared statements much better against mysql injection.
  19. Are you sure that $_POST["navn"]) will always be "please fill this out"? Everything else is in Danish, so this seems kind of strange.
  20. Can you repost the code including the $_POST validation you just added?
  21. Submit buttons are special creatures. You can filter them out. I also added asnippet to check against values with only whitespace: <?php foreach($_POST as $field => $value) { if (($field != 'submit') && ((!$value) || (trim($value) == ''))) { $err .= "$field cannot be empty. <br>"; $warnings[$field] ="required"; } } ?>
  22. I only gave that as an example. You should replace the "//Alert the user" with something useful, otherwise the } will be regarded as part of that comment.
  23. What data is there in the table and which output are you expecting?
  24. That's the way I understood it. Can you post the GET function here?
×
×
  • 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.