Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Daniel0

    Class vs. ID

    I believe IDs have to be unique in order to have valid XHTML (possibly HTML too). So imagine a forum system, where each post row has an ID called 'postrow', that would not make the ID unique, so you'd have to use the classes instead.
  2. [quote author=godsdead link=topic=99757.msg392961#msg392961 date=1152257222] This code isnt working in my stand alone server running: Apache 2.0 PHP Version 5.1.1 [code] <?php switch($x){ case"": echo"Hello"; break; case"work": echo"WORK DAMIT!"; break; } ?> [/code] Okie one of the most simplest codes and it wont WORK when i go to [b]?x=work[/b] :@! This should work as it works on my online server, but i really need it to work on my home server! the script runs useing this: [code] <?php $x = $_GET[x]; switch($x){ case"": echo"Hello"; break; case"work": echo"WORK DAMIT!"; break; } ?> [/code] with the [b]$x = $_GET[x];[/b] variable, Also i realised i cant process any forms unless i use this! which is Sooooooooo Anoying! as all my scripts have basically ******! please help! [/quote] Your example code will only work if register globals is turned on.
  3. Sure it is, but sometimes people may not be able to code a feature/function themself. But looking at other people's code is a great way to improve your own coding skills if you are not very good in a certain language, I think.
  4. Daniel0

    Add mUsic

    If you are going to add background music on your website, make sure you can turn it off, because I believe many people, like myself, find it extremely annoying.
  5. Chances are that the MP3 file exceeds 1000000 bytes (0.95 mb). Either change the value of the hidden field MAX_FILE_VALUE or completely remove it.
  6. You might want to look at this site's [url=http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php]pagination tutorials[/url] :)
  7. You would have to use [url=http://php.net/intval]intval[/url] or [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string[/url] on the variable $tutid if you choose not to enclose the value in quotes in the query to ensure that people to not exploit your code inject another query the initial query.
  8. You could [url=http://php.net/serialize]serialize[/url] the array, put it in the link and then [url=http://php.net/unserialize]unserialize[/url] at the other page. Example: [code] <?php $data = serialize($_REQUEST); echo "<a href='what-ever-page.php?data={$data}'>Back</a>"; ?> [/code] (If you'd like to use POST or GET instead of REQUEST you just replace it) Another solution would be to use [url=http://php.net/http_build_query]http_build_query[/url] to build a query string automaticly for you. You need to use PHP5 though. Example: [code] <?php $data = http_build_query($_REQUEST); echo "<a href='what-ever-page.php?{$data}'>Back</a>"; ?> [/code]
  9. You could use [url=http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html]mod_rewrite[/url] to make it look in another way.
  10. It's used to display the value of a variable inside a string enclosed in double quotes.
  11. I made an example script for you here: [code]<?php /** * Check password level script * * A script made to demonstrate how password levels could be calculated * * @author Daniel Egeberg */ /** * Password level * * A function made to calculate password strength * * @param string $password The password to check * @return integer */ function password_level($password) { $level = 0; if(strlen($password) >= 6) { $level++; } if(preg_match('/[0-9]/',$password)) { $level++; } return $level; } /** * Display form * * Used to display the form with an optional message * * @param string $message An optional message * @param string $password Used to fill-out the form */ function display_form($message=null,$password=null) { $message = !empty($message) ? "<strong>{$message}</strong>\n\n" : null; echo <<<EOF {$message}<form action='{$_SERVER['REQUEST_URI']}'> <label>Password: <input type='text' name='password' value='{$password}' /></label> <button type='submit'>Calculate password level</button> </form> EOF; } if(!empty($_GET['password'])) { display_form("Your password strength is at level ".password_level($_GET['password'])); } else { display_form(); } ?> [/code] I am not sure what you mean with if it contains characters, so I did not implement that, but I'm sure you can figure out how to do so based on this example script.
  12. Hey, You might want to check out the [url=http://pear.php.net]PEAR[/url] package called [url=http://pear.php.net/package/HTML_BBCodeParser]HTML_BBCode_Parser[/url]. It's a package already written for people who would like to use it and it comes with a [url=http://pear.php.net/package/HTML_BBCodeParser/docs]documentation[/url].
×
×
  • 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.