Jump to content

Wuhtzu

Members
  • Posts

    702
  • Joined

  • Last visited

    Never

Everything posted by Wuhtzu

  1. Haha yeah! In Denmark you can get a TI89 for 1339 DKK (how come they don't charge 1337 DKK - As a show owner I would gladly pay 2 DKK for having that price) which is about $265 or 179 eur
  2. I can see that GingerRobot - it is unfair if some students are allowed to bring it and some are not. But I guess the "No" is simply based on some students having the calculator (because they bought it) and some students not having it (because they didn't buy it due to lack of knowledge about it or finance)? And no hard feelings here - it's all with a smile - I'm just curious
  3. Doesn't everybody has the option of using a TI calculator at the exam you speak of?
  4. The reason why you are allowed to use it is because CAS tools allow you to explore more math than you could possibly do with a pencil and paper - given the time a normal youth education is, which is around 3 years or so. Why waste time e.g. integrating / differentiating huge expressions when you know the concept and are able to do it given enough time? Now I don't know where you live and educate your self, but in Denmark most classes / courses / subjects have two exams - one with aid (calculator, Maple, Mathcad ect.) and one without aid (just pencil and paper)... and sometimes oral exams too. This way all your skills are being tested. Your ability to comprehend and solve complex problems (with aid), your ability to do basic math such as integration, solve equations (without aid) and your ability to "understand" and explain math such as constructing and understanding proofs (oral). Above example is of course from a math course. This is how it is done in our gymnasium (high-school I guess - 11th to 13th school year) and also to some extend in our Universities.
  5. The rewrite rule does what you want .... and if it for some reason does not please tell us exactly what's wrong. Because I wrote the rule to do what you said...
  6. Wrong board... but # URL rewriting RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9]+)$ broker/index.php?url=$1
  7. This sounds like you (he) knows how to use mod_rewrite to perform basic rewriting.... e.g. turning /123 into ?id=123. So that is now his problem. The id too comes from the database... right now you have just chosen to use the id to look up the product. Now you just have to use the product name to look up the product instead. This means making a rewrite rule that rewrites http://domain.com/Possibly_CamelCased_ProductName to http://domain.com/item.php?product_name=Possibly_CamelCased_ProductName (100% analog to what you said you found instructions for) and adjusting your script: <?php $product_name = $_GET['product_name']; $get_product = mysql_query("SELECT * FROM products WHERE product_name = $product_name"); //display the product ?> This is of course simplified as the product name with _ as separator probably have to be converted to use space as separator and convert all to lowercase ect.: <?php //Make the product name obtained from the url lower case and replace _ with space $product_name = strtolower(str_replace('_', ' ', $_GET['product_name'])) //Query the database for the product, making sure it check the lower case name against a lower case name $get_product = mysql_query("SELECT * FROM products WHERE LOWER(product_name) = $product_name"); ?> And yes, you have to change your links. For example your menu / navigation have to look like this now: <a href="/Nifty_Gadget">Nifty Gadget</a> <a href="/Smart_Self-Digging_Spade">Smart Self-Digging Spade</a> Again, explain your problem in more detail if I didn't answer your question
  8. Wuhtzu

    How do i..

    What is "a whole html" ? And we need more information about the format of the "generated strings".... do they have a specific length, consist only of specific characters, start and end in a specific manner or are they within a specific tag?
  9. You just have to avoid this or present the two possible products if the query based on the product name returns two rows. Right now you must have something like this: item.php: mydomain.com/item.php?id=123 <?php $id = $_GET['id']; $get_product = mysql_query("SELECT * FROM products WHERE id = $id"); //display the product ?> If you want the product name instead you should just base your query on that: item.php: mydomain.com/item.php?product_name=123 <?php $product_name = $_GET['product_name']; $get_product = mysql_query("SELECT * FROM products WHERE product_name = $product_name"); //display the product ?> or you could allow both: item.php: mydomain.com/item.php?id=123 or mydomain.com/item.php?product_name=123 <?php $id = $_GET['id'] $product_name = $_GET['product_name']; if($id) { $get_product = mysql_query("SELECT * FROM products WHERE id = $id"); } elseif($product_name) { $get_product = mysql_query("SELECT * FROM products WHERE id = $id"); } else { echo "No product selected"; } //display the product ?> If the above didn't answer your question please explain more about exactly what you don't understand / don't know how to do
  10. Then shouldn't we refer to a installation guide... a PHP interpreter needs to be installed as well as that line added to the apache config file. http://php.net/install.windows
  11. Sorry to say it Mika, but if PHP is poorly configured <? ... your code ... ?> should work You should favor <?php ?> tags over <? ?> But other than that mika is completely right. You simply put your php code inside an opening and a closing tag: <html> <head> <title><?php echo $title; ?></title> </head> <body> <p><?php echo $something; ?></title> </body> </html>
  12. Simply loop over the directory and check if the file meet your requirements and if it does add 1 to a counter: <?php $num_of_text_files = 0; if ($handle = opendir('/path/to/files')) while (false !== ($file = readdir($handle))) { if(preg_match("/\.txt/$", $file)) { $num_of_txt_files++; } } closedir($handle); } echo "There is $num_of_text_files files with the extension .txt in the folder"; ?> Of course you can do your "testing" different.... preg_match just seemed easiest for me to write Edit: Corrected a weird sentence and I missed a ) in an if-statement
  13. #1: I will personally call RewriteBase good practice since your rewrite rules looks cleaner / more simple and you can easily apply a change in your directory structure to all your rules without having to change each rule. #2: As I said in the post I posted a link to, you have the full power of regex as your disposal, so you can simply make the trailing slash (/) optional: RewriteRule ^([a-zA-Z0-9]+)/myFolder/([a-zA-Z0-9]+)/?$ foobar.php?foo=$1&bar=$2 The question mark (?) means 0 or 1 instance of the preceding character. So 0 or 1 instance of the trailing slash (/)
  14. First of all may I refer you to this post: http://www.phpfreaks.com/forums/index.php/topic,175754.msg778928.html#msg778928 - just because it is somewhat informative. Secondly the rewrite rule you are after is pretty simple: .htaccess: # URL rewriting RewriteEngine on RewriteBase /sandbox/rewrite/ RewriteRule ^([a-zA-Z0-9]+)/myFolder/([a-zA-Z0-9]+)/$ foobar.php?foo=$1&bar=$2 foobar.php: <pre> <?php print_r($_GET); ?> </pre> The rewritebase is set to /sandbox/rewrite/ because I did this rewrite test at http://wuhtzu.dk/sandbox/rewrite/foobar.php - you can try it here and see if it does what you expected: http://wuhtzu.dk/sandbox/rewrite/foo/myFolder/bar/ Change the rewritebase to what ever suits your folder / file structure
  15. And I'm still confused about your images You explain almost less than nothing about your problem with some images. Your initial post made it sound like you had trouble making a rewrite rule that would accept for example a date yyyy-mm-dd. Please explain some more about those images, whats wrong with them and what should they do / look like!
  16. Hey What is the best way to go around form handling in the MVC design pattern? With form handling i mean validating the input, display messages to the user and save data. Especially the displaying messages to the user I find tricky to get my head around. If some of the inputted data fails validation I need to display an error message to the user and if the data passes validation I need to display a success message. Since you don't want any control structures in your view, how do you go about displaying messages to the user? You could of course have multiple views to cover a single form, but that wouldn't be very neat. Should one write a form handler which takes care of the validation and message displaying so it is stashed away from the view - sort of what CakePHP does with it's html-helpers? I would really appreciate some inputs from you guys Thanks Wuhtzu
  17. <? only works if you have enabled short tags in your php.ini http://dk2.php.net/ini.core
  18. mod-rewrite can be quite tricky to work with but when you get the hang of it, it is quite easy. And a part of getting it is to start out with the proper syntax and "tools": #1: The "syntax" of your .htaccess file should be: RewriteEngine on RewriteBase /path/from/your/webroot/to/your/rewrite/script/ RewriteRule ^([a-z]+)/([a-z]+)$ script.php?key1=$1&key2=$2 RewriteEngine on turns on the rewrite engine (if you have permissions to) RewriteBase /path/from/ sets the rewrite base. If domain.com points at your webroot and you want to do rewriting at domain.com/test/products/script.php (obtaining e.g. domain.com/test/products/6123) then you should set your rewritebase to "/test/products/". You save your self a lot of headaches by doing this. RewriteRule ^([a-z]+)/([a-z]+)$ script.php?key1=$1&key2=$2 the rewriterule uses regular expression to match part of the url (from your rewritebase and forward / reading left to right) and "saves" those matches as $1, $2, $3 ... $n which you can then stick in your script.php?key1=$1&key2=$2&keyn=$n. #2: Realise that you have the full power of regular expression at your disposal when you use mod-rewrite. Syntax of the rewriterule is: RewriteRule ^(pattern1)/(pattern2)/(pattern3)$ script.php?key1=$1&key2=$2&key3=$3 RewriteRule ^(pattern1),(pattern2),(pattern3)$ script.php?key1=$1&key2=$2&key3=$3 RewriteRule ^(pattern1)-(pattern2)-(pattern3)$ script.php?key1=$1&key2=$2&key3=$3 Where / , and - are delimiters separating the patterns to match. Of course ^ and $ are optional - they just anchor the matching to start at the beginning of the url (from your rewritebase an onwards) and end at the end. I can't think of a scenario where you wouldn't want to use them. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Now on to your "question" where you wanted to create some more "advanced" rewriting rules. Take a look at the following .htaccess: # URL rewriting RewriteEngine on RewriteBase /sandbox/rewrite/ RewriteRule ^([0-9]{4}-[0-9]{2}-[0-9]{2})/([a-z]+)/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$ rewrite.php?date=$1&string=$2&ip=$3 RewriteRule ^([0-9]{4}-[0-9]{2}-[0-9]{2}),([a-z]+),([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$ rewrite.php?date=$1&string=$2&ip=$3 RewriteRule ^([0-9]{4}-[0-9]{2}-[0-9]{2})-([a-z]+)-([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$ rewrite.php?date=$1&string=$2&ip=$3 rewrite.php: <pre> <?php print_r($_GET); ?> </pre> I am doing my rewriting on this script http://wuhtzu.dk/sandbox/rewrite/rewrite.php and therefore my rewritebase is "/sandbox/rewrite/". Try the script here: http://wuhtzu.dk/sandbox/rewrite/1998-12-06/lol/123.456.789.000 http://wuhtzu.dk/sandbox/rewrite/1998-12-06,commadelimiter,123.456.789.000 http://wuhtzu.dk/sandbox/rewrite/1998-12-06-anotherdelimiter-123.456.789.000 As you can see my .htaccess file contains 3 almost identical rewriterules, they only differ by the delimiter (/ , -) and the rewrite rules each consists of 3 patterns: ([0-9]{4}-[0-9]{2}-[0-9]{2}) which matches a date formatted as yyyy-mm-dd ([a-z]+) which matches a string longer that 1 char ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) which matches an IP address You should be able to recognize the very basic perl style regex. Hope this helps you Wuhtzu EDIT: a few typos
  19. People with a 20 Mbit/s connection can theoretically accumulate quite a lot of traffic over the course of a month: 20 Mbit/s = 2.5 MB/s 2.5 MB/s * 30 * 24 * 60 *60 s/month = 6480000 MB = 6.5 TB/month That is double the amount of traffic www.servage.net allows per month... But I guess those ISP's have taken into account the amount of traffic fast connections create.
  20. Your syntax is wrong, this is correct: $CampusID = "Campus " . $NumberOfRecords+1; or $CampusID = "Campus" . " " . $NumberOfRecords+1; . (dot) is used to join strings and variables together so the correct syntax is like: $new string = "string" . "anotherstring" . $variable . "yet another string" . $andavariable;
  21. Just get a host where you know the exact amount of data transfer you can use every month, because hosts that offer "unlimited data transfer and 1-3GB of storeage" don't mean unlimited datatransfer. I had such a host one time - www.web10.dk (danish company) - and they offer "fri trafik" which means unlimited / as much as you like / free trafic, but I once hosted a 200MB file that got downloaded as little as 10 times and they shut down my account because I used too much trafic. So go with something like www.servage.net where you know you have 3600GB data transfer per month. Btw. I wouldn't recommend a host with servers physically located in Germany (europe) if you are looking for quick response times in the US - choose a domestic host.
  22. Red Hair, simply because it's cute .ISO or .BIN / .CUE
  23. Agreed redbullmarky - it is Christmas/New Year and people are doing family stuff!
  24. I would personally go with a host with high amount of bandwidth and storeage - not a vps. www.servage.net, which is a danish company based in Germany, offers 360GB of storeage and 3600GB of data transfer per month for only 39 DKK which is around $7.7 / 5.3 eur / £3.8. You could have 2 of such accounts giving 720 GB of storeage and 7200 GB of data transfer per month or make a deal with them regarding more storeage space and data transfer. I personally wouldn't go with a VPS when you need lots of storeage space. They are primarily aimed at sites / web services with the need for custom / special (not apache + php + mysql) software and not for storing large amounts of video.
  25. Sliced Bread since it is much harder to slice bread than to slice cheese... at least as long as you use a freehand knife to slice the bread Would you rather read Books in the language they were originally written (if you understand it) or Books translated to your first language ?? (E.g. a frenchmen who reads Harry Potter in english rather than french or the other way round)
×
×
  • 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.