ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
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">
-
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.
-
Search engines don't like redirects.
-
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-
-
Including file to extend switch statement options
ignace replied to Airhead315's topic in PHP Coding Help
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 -
Nice. I won't be using it for this particular purpose, but good to remember.
-
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
-
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, ..); } } } }
-
[SOLVED] Controlling Javascript with php???
ignace replied to craigtolputt's topic in PHP Coding Help
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. -
Nope but you can always write it http://www.pages.drexel.edu/~weg22/can_tut.html
-
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.
-
oni-kun: $emo = stripslashes($wrist); should be: $emo = addslashes($wrist); Plus, you shouldn't discriminate people.
-
[SOLVED] Need a way to let users upload music, images, ...
ignace replied to DEVILofDARKNESS's topic in PHP Coding Help
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 -
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); } }
-
LOL thorpe date('H:i', time()); 10:53
-
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
-
[SOLVED] PHP newbie, can't understand error message! :(
ignace replied to Zoroaster's topic in PHP Coding Help
$count = mysql_num_rows($result); instead write: if ($result && ($count = mysql_num_rows($result))) { .. } -
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
-
Using variable variables ($ and $$) to change array name?
ignace replied to TQ_designs's topic in PHP Coding Help
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); -
Then you have read a different manual then I did: http://dev.mysql.com/doc/refman/5.0/en/non-typed-operators.html
-
That's why you need the CSS this will put them next to each other. You can atleast try the solutions we provide.
-
Can't access system environment variables from PHP
ignace replied to cyberfinn's topic in PHP Coding Help
Have you restarted Apache? otherwise the modified variables_order won't be in effect -
<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] ..