Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Have you set encoding to ISO-8859-1? PHP: ini_set('default_encoding', 'ISO-8859-1'); HTML: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  2. It is very important that you only use 'or die()' during debugging never ever use it in a production environment your visitors don't know what: "Could not Execute Query on table SomeTable: Query was empty" means. Always display a nicer message telling them what happened and what they can do next.
  3. Search engines don't like redirects.
  4. No it isn't your headers can only be http response headers (http://www.w3.org/Protocols/HTTP/Object_Headers.html) or custom headers starting with X-
  5. As Neil already pointed out you need the MVC pattern. However chances are you don't want to write your own MVC. Luckily you are not alone on this planet and millions have written frameworks (meaning that you will get more then you came for) that incorporate the MVC pattern for you. A comprehensive list can be found at Wikipedia: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#PHP Before you start tik-tak-to'ing to select your framework. There are a few things you need to know about frameworks. Frameworks come in different forms: Full-stack frameworks: These frameworks gather multiple libraries useful for web development into a single cohesive software stack for web developers to use. These usually also lay the foundation (bootstrap, pre-determined controller directory, ..), examples of these frameworks: - CakePHP - CodeIgniter - .. Component-frameworks or traditional frameworks: - Zend Framework - .. These are the more popular frameworks
  6. Nice. I won't be using it for this particular purpose, but good to remember.
  7. can you please keep it to 1 topic? http://www.phpfreaks.com/forums/index.php/topic,265372.msg1251308.html http://www.phpfreaks.com/forums/index.php/topic,265228.msg1250794.html
  8. I am assuming that you want to send an e-mail to specific groups of people. $list1 = array(..);//list of e-mail addresses $list2 = array(..); define('EMAIL_LIST_SUBSCRIBERS', 'subscribers'); define('EMAIL_LIST_MANUFACTURERS', 'manufacturers'); $final_list = array(); if ('POST' === $_SERVER['REQUEST_METHOD']) { if (!empty($_POST['list'])) { switch ($_POST['list']) { case EMAIL_LIST_SUBSCRIBERS: $final_list = $list1; break; case EMAIL_LIST_MANUFACTURERS: $final_list = $list2; break; } if (!empty($final_list)) { foreach ($final_list as $email_address) { mail($email_address, ..); } } } }
  9. add an extra parameter to the form action="" for example ?expand=true read the query using js and split it and if expand == true then don't subtract it.
  10. Nope but you can always write it http://www.pages.drexel.edu/~weg22/can_tut.html
  11. What are you actually trying to accomplish? Do you want to read a php file, then search for all echo statements and add slashes to strings? You probably need to extend it as ' is also valid.
  12. oni-kun: $emo = stripslashes($wrist); should be: $emo = addslashes($wrist); Plus, you shouldn't discriminate people.
  13. Most likely you want to create a directory for each and every user to store their media, however when doing so you will not only allow them but also every visitor that stumbles upon it can sniff those directories. You can use .htaccess, but do you possess the skill to write the required complex code? and is it worth the effort? Personally I would create the upload system using PHP as it allows the fine grained control I want and it keeps it simple. P.S. type(enum) Just some advice, don't use an enum but use a varchar instead. Create constants that holds certain values and can be used throughout your application: define('MEDIA_TYPE_IMAGE', 'image'); define('MEDIA_TYPE_VIDEO', 'video'); define('MEDIA_TYPE_MUSIC', 'music'); INSERT INTO table VALUES ($users_id, $poems_id, MEDIA_TYPE_*) switch ($type) { case MEDIA_TYPE_IMAGE: //logic break; case MEDIA_TYPE_VIDEO: //logic break; case MEDIA_TYPE_MUSIC: //logic break; } This way you can avoid typo's (and decrease bugs) as an undefined constant throws a notice but is converted to a string ("MEDIA_TYPE_MUSIC") while a typo is valid nonetheless
  14. If you want every fourth element to move to the first place, use: $sizeof = sizeof($menuArray); for ($i = 1; $i <= $sizeof; ++$i) { if (0 === ($i % 4)) { $temp = $menuArray[$i]; unset($menuArray[$i]); array_unshift($menuArray, $temp); } }
  15. http://be.php.net/curl
  16. LOL thorpe date('H:i', time()); 10:53
  17. Like you already pointed out floating points in PHP are not exact and the manual tells you to use the arbitrary precision math functions as they do what their name says. http://www.php.net/manual/en/ref.bc.php
  18. $count = mysql_num_rows($result); instead write: if ($result && ($count = mysql_num_rows($result))) { .. }
  19. games ------ id cat_id name category -------- id cat rating ----- game_id rating count SELECT games.name, category.*, rating.rating, rating.count FROM games LEFT JOIN category ON games.cat_id = category.id LEFT JOIN rating ON games.id = rating.game_id
  20. echo current($arr$i); //I know this is illegal syntax - need proper way to do the same thing $arrayName = 'arr' . $i; $array = ${$arrayName}; echo current($array); next($array);
  21. Then you have read a different manual then I did: http://dev.mysql.com/doc/refman/5.0/en/non-typed-operators.html
  22. That's why you need the CSS this will put them next to each other. You can atleast try the solutions we provide.
  23. Have you restarted Apache? otherwise the modified variables_order won't be in effect
  24. <form> <?php while ($row_questions = mysql_fetch_assoc($questions)) { ?> <select name="name[<?php echo $row_questions['question_id']; ?>]"> <option value="">Select</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <?php } ?> <input type="hidden" name="user" value="Current user" /> <input type="submit" name="submit" id="submit" value="submit" /> </form> You can now access every question using $_POST['name'][$row_questions['question_id']] like: $_POST['name'][1] $_POST['name'][2] $_POST['name'][3] ..
×
×
  • 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.