Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You are missing the recaptcha_check_answer() function call which returns you a response object on which you can check if the response was valid as part of your form validation. <?php $response = recaptcha_check_answer('your-secret-key', $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if ($response->is_valid) { // valid captcha response } ?> The full explanation can be found on http://recaptcha.net/plugins/php/
  2. why? <?php $csv .= 'img_src500,'; $csv = substr($csv, 0, -1)."\n"; ?> as this is the same as: <?php $csv .= 'img_src500'; ?> can you also provide a sample of what it gives you?
  3. please post some code
  4. could you please post some code?
  5. onsubmit="SignIn_SubmitForm(); return true"
  6. Some thing i forgot to mention is when you start re-factoring your code you should always take baby-steps re-factor something small (never re-factor something big because then you would be doing something wrong) out of your code and check if it still works and then continue with the next thing and continue to do so until you end up with something that you can not re-factor further or you can easily tell what your program is doing.
  7. Possible solutions: Problem 1) first: Code looks good although you may want to remove the html from your php code you could use a template engine like Smarty. Second: Refactor your code.. Third: Refactor your code... Fourth: Refactor your code... Try to find small pieces in your code which you end up using multiple times or which you may end up using more then once, wrap it, and give it a proper name if done well you will find your program less complex to code. You could see this like a book the paragraph titles immediatly tell you what will follow which in turn helps you to understand your program more easily much like your comments. Consider the following example which i created based on your code: <?php // Error reporting error_reporting(E_ALL); // Connect DB $db = mysql_connect("wickettowicket.adminfuel.com", "xxxxxxxxx", "xxxxxxxxxxx") or die(mysql_error()); // Select DB mysql_select_db("wickettowicket") or die(mysql_error()); $batsmen = setupBatsMen($db); $bowlers = setupBowlers($db); $data = gameLoop($batsmen, $bowlers); echo createScoreCard($data); ?> You must realise that these functions proxy to other functions not currently shown here. But you directly see what is going on and the complexity has decreased in a tremendous way. Problem 2) A simple loop over your batsmen will do the trick Problem 3) I have no knowledge of cricket so i can not help you with that explain the problem more precisely to get more precise solutions Problem 4) Same like 3 or something like: if ($bowler['bowl'] > 10) { ..logic.. } You could also wrap your bowler's into objects if ($bowler->reachedMax()) { ..logic.. } or something alike.
  8. Use the multiple="multiple" option on your select element which allows you to select multiple categories at once <?php if (isset($_GET['removecat'])) { ?> <p class="admintxtl">Remove Category</p> <form enctype="application/x-www-form-urlencoded" action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post"> <p><span class="admintxt">Remove Category</span><br /> <?php $query='SELECT * FROM category ORDER BY \'catname\''; $result = mysql_query ($query); echo '<select name="removecats[]" multipe="multiple">'; while($nt=mysql_fetch_array($result)) { echo "<option value=\"{$nt['id']}\">{$nt['catname']}</option>"; } echo '</select>'; ?> <input type="submit" name="removecat" value="Remove Category" class="admintxt" /> </form> <br /> <br /> </p><?php } ?> <?php if (isset($_POST['removecat'])) { $query = 'DELETE from category WHERE id IN ('. implode(', ', $_POST['removecats']) .')'; echo $query;// debug mysql_query( $query ) or die (mysql_error()); echo "<html><head><meta http-equiv='refresh' content='5;url=admin.php?main'></head>"; echo "<p class='bigtext'>".$_POST['category']." removed from the database".$proceed; exit; } ?> Your problem was that you named your submit button the same as your select element tag. I have renamed your select name="removecats" (plural) P.S. Your code is a mess. I strongly advice separating your html from your php as much as possible.
  9. Personally i use one of these two scripts for resizing images based on what i read i would suggest using the first one: - http://shiftingpixel.com/2008/03/03/smart-image-resizer/ - http://mediumexposure.com/techblog/smart-image-resizing-while-preserving-transparency-php-and-gd-library If you don't want to use existing scripts you can read through the code to see how they tackled the problem
  10. <?php $query = 'SELECT memtype, count(*) as memtype_cnt' . ' FROM members' . ' GROUP BY memtype'; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { echo $row['memtype'] . ' ' . $row['memtype_cnt'] . '<br />'; } ?> will display: FREE 100 PRO 100 JVPARTNER 100
  11. Isn't this the same like with images? Where you use a .htaccess to redirect any inbound direct linking to another specific resource? Something along the lines of: http://www.selfseo.com/story-18469.php (How to block direct image linking)
  12. include the script that does the include of include('config.php');
  13. instead of reading it yourself you could also just use scandir() http://be2.php.net/manual/en/function.scandir.php btw if($file == ".") continue; if($file == "..") continue; is the same as: if ($file[0] === '.') continue; which also covers both
  14. at what method are we supposed to look at?
  15. add this code: // assume this month $month = date('m', $date); // change if a valid month has been supplied if (isset($_POST['month']) && !empty($_POST['month']) && is_numeric($_POST['month'])) { $postMonth = (int) $_POST['month']; if ($postMonth >= 1 && $postMonth <= 12) { $month = $postMonth; } else if ($postMonth > 12) { $month = 1; } else if ($postMonth < 1) { $month = 12; } unset($postMonth); } probably you want to add this functionality to your submit buttons: <?php function monthCarousel($currentMonth) { if ($currentMonth >= 1 && $currentMonth <= 12) { return $currentMonth; } else if ($currentMonth < 1) { return 12; } else if ($currentMonth > 12) { return 1; } } ?> <input type="submit" name="previous" id="previous" value="<?php print monthCarousel($month - 1); ?>" /> <input type="submit" name="next" id="next" value="<?php print monthCarousel($month + 1); ?>" />
  16. $headers = "From: $email_from .\n"; "Reply-To: $email_from .\n"; is wrong and should be: $headers = "From: $email_from\n". "Reply-To: $email_from\n"; -------------------------------------- ini_set("sendmail_from", $email_from); why set the from twice? -------------------------------------- i would really encourage adding some anti-spam method and some validation on everything what you get from $_POST -------------------------------------- P.S. use ' (single quote) instead of " (double quote) only use double if you need to parse something in the string like: $headers = "From: $email_from\n". "Reply-To: $email_from\n"; otherwise use ' (single quote)
  17. The reason you are getting one thing and one thing only is because you are always overwriting your container: $state='<option value="'.$row['id'].'"'.($row['id']==$intSelectID ? ' selected="selected"' : '').'>'. $row['state'].'</option>' should be: $state.='<option value="'.$row['id'].'"'.($row['id']==$intSelectID ? ' selected="selected"' : '').'>'. $row['state'].'</option>' notice the dot after $state now you concatenate your strings, i used the shorthand version though the long version is: $state= $state . '<option value="'.$row['id'].'"'.($row['id']==$intSelectID ? ' selected="selected"' : '').'>'. $row['state'].'</optio a mistake both Yesideez and you made!
  18. @ToonMariner thank you i'll have a read i'm keeping the topic open for any other suggestions though
  19. Hello, Has anyone any experience with OO Analysis & Design or Behavior Driven Development? Or any other methodology? And can you give me some examples. I really want to get the hang of this but i can not find any decent article on the internet Thanks in advance
  20. Well, I didn't really found an SQL query for it, but instead i used mysql_fetch_field() which provides me with the meta data.
  21. Assuming your database looks like: rooms (rooms_id, rooms_beds, rooms_price, ..) customers (customers_id, customers_name, ..) bookings (bookings_id, bookings_customers_id, bookings_rooms_id, bookings_reservation_date, bookings_check_in, bookings_check_out, ..) Then the code would be something similar like: SELECT count(*) as available_rooms FROM rooms WHERE rooms_id NOT IN ( # select all rooms wich are currently in use or will be used soon SELECT bookings_rooms_id FROM bookings WHERE (bookings_reservation_date > NOW() AND bookings_reservation_date < NOW() + 14) # room reservation within 14 days (adjust if needed) OR bookings_check_out IS NULL # a customer is already using the room and has not yet checked_out );
  22. Don't bother i've found it
  23. I am using a program to manage my databases and everytime i execute a query it gives me the header name (as it should) and its data type. Now am i wondering how can i do the same thing? Has anyone any experience with this?
  24. No i didn't try to float them, but are you suggesting that this is my only option?
×
×
  • 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.