
LordDan
Members-
Posts
66 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by LordDan
-
I don't see how correcting chinion's code with proper concatenation then discussing what concatenation is and the methods of using it, is off topic. :huh:
-
That makes sense, I understand that.. :thumbup:
-
Whilst we're on the subject of echo and concatenation methods, anybody use (,) rather than concatenation (.) when using echo? echo $myName ,' is ', $awesome; I was told it is faster than Concatenation and only works with Echo, I've tried it with echo and it does work without error. Anyone else seen/used this?
-
I personally used KillerPHP.com way back then, i found his videos to be 100% detailed and explanatory. Give them a try to get started, I was 15 when i learn and it takes about 6 months to learn and remember enough to start making a website, give or take a few months depending on your Intellect.. I'm stupid, so 6 months for me. :thumbup:
-
Is it just me, or is MySQLi just even more lines of code? I've never used it myself, so I did a little search, seems most developers regard MySQLi as a failure and say stick with MySQL, so what gives? ?(
-
It's better but it will still error (For me with error reporting). It will work though. $search = $_POST['search']; $submit = $_POST['submit']; Everytime you enter the page you are placing posted date into a variable, but if you just entered the page and not posted yet, you'll get $search undifined index error. Place this at the top of the script, and you will see what i mean@ <?php error_reporting(-1); ?> To fix, i used if isset to only collect $search if we actually submitted.. if( isset( $_POST['submit'] ) ){ // You dont need to store this into a variable as we're only using it here // Now code in here will only be run if $_POST['submit'] is-set... // Now we can move onto getting our search term. if( !isset( $_POST['search'] || empty( $_POST['search'] ) ) ){ // No point searching without a search term die( 'Please enter a search term!'); } // If we made it this far without the die() triggering above, // we should be good to continue.. $search = mysql_real_escape_string( $_POST['search'] ); // Add any additional filtering to $search an continue MySQL here } Now nothing is undefined because we're only executing our search code if we have actually pressed the Search Button :) Good luck, hope that helps you out a little more, and remember to use the error_reporting(-1);, it'll help you improve the quality of your code greatly. :thumbup:
-
Hmm, I'm going to be really picky now, but i develop with error reporting set to -1 (Better than E_ALL) and this will spit out errors.. # NO, NO, NO! $search = $_POST['search']; $submit = $_POST['submit']; if($submit){ # Use error reporting people! It'll force good habits!!! (Extra Spacing used for clarity) if( isset( $_POST['submit'] ) ){ if( !isset( $_POST['search'] ) ){ # Change depending on how you report user errors. header('location: search.php?error='. urlencode( 'Please enter a search term.' ) ); exit; } else { # Why no security? 0_o $search = mysql_real_escape_string( $_POST['search'] ); # Contunue the rest.... # PHP PHP PHP PHP PHP........ } } So, not to be picky, I know you said "basic" but all those years ago when i started learning PHP, i used tutorials posted in forums just like this and as a result i had bad habits and messy code. It took a while before some Pro told me to stop reading crap quality posts and buy a book. Basically, what I am saying is, basic example or not, use good habits for the sake of those wanting to learn ^^
-
Okay, well the table's <td> will need ID's if you want to get the value from it. <table><tr><td id="td1">Meh Value!</td></tr></table> Using the ID, you can get the value as such; <script type="text/javascript"> // Get the value var val = document.getElementById('td1').innerHTML; // Meh Value! // Change the value document.getElementById('td1').innerHTML = 'Meh new value!'; </script>
-
Suggestion: Add a few screenshots to your front page, I'm not a fan of signing up just to see what it looks like. If I can't see what the game looks like without signing up, I never bother. :thumbup:
-
Hmmmm, if i remember correctly you can get the contents of a Frame/iFrame with window.frames.. I am going to assume the iframe has an ID of "myIframe", in the iFrame is a form with an id of "myForm" and a hidden input with the id "myInput".. I cannot guarantee this will work, but try this.. var myValue = window.frames['myIframe'].document.forms['myForm'].elements['myInput'].value And of course you should be able to set a value within an iFrame too. window.frames['myIframe'].document.forms['myForm'].elements['myInput'].value = "Boobies"; Give that a try. :thumbup:
-
I use WeBuilder 2010, so far it's had everything i have needed. :rolleyes: I use it for plain text as well as Web Development.
-
I've used Ajax quite a bit, moved to jQuery Ajax since, but can use both. I would help, but unfortunately, I'm not Psychic.... Code? Also, is this your own code or part of an OpenSource project you downloaded? Also, use Firefox and download FireBug, it's essential for Client Side debugging.. I would have avoided all Client code if it wasn't for FireBug.
-
Yeah, I took it down because I am rebuilding it based on some advice from a_bertrand :)
-
Oh don't get me wrong, I will support them, of course, I love my country. I have just found my own alternative.. I listen via radio instead, that way I won't be bored watching it and I can still do what I want to do. ^^ But anyway, I don't care if we win the Cup is what I mean by "don't care"..
-
I personally don't care, I'm not even watching it.. It's so freaking boring 0_o ... Not a massive fan of sport me :S
-
Because I didn't write it, I just did a search and posted as reference ^^ I've never needed such a function myself..
-
function exchangeRate( $amount, $currency, $exchangeIn ) { $googleQuery = $amount . ' ' . $currency . ' in ' . $exchangeIn; $googleQuery = urlEncode( $googleQuery ); $askGoogle = file_get_contents( 'http://www.google.com/search?q=' . $googleQuery ); $askGoogle = strip_tags( $askGoogle ); $matches = array(); preg_match( '/= (([0-9]|\.|,|\ )*)/', $askGoogle, $matches ); return $matches[1] ? $matches[1] : false; } echo exchangeRate( 1000, 'euro', 'dollars' ); This what you mean?
-
If I remember correctly, this can only happen if you have something like "allow_url_include" or some similar setting in PHP INI enabled, by default, it should be disabled for security If you wish to test, try and include a page on your own server but include the full address "http://www.yoursite.com/globals.php" you "should" get something like Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\temp\prev0~.php on line 9 Warning: include([url]http://www.google.com/globals.php[/url]) [function.include]: failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\temp\prev0~.php on line 9 Warning: include() [function.include]: Failed opening 'http://www.google.com/globals.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\temp\prev0~.php on line 9 Tested on google..
-
Sex trafficking has been done already :S :huh: :pinch: Hmm, if I had one wish.. It'd be... To move to Aussie Land ^^
-
They're the same and share the same need of user input validation.. The only difference is that Require() spits out an E_ERROR is the file doesn't exist. Both of them are only insecure if you're allowing user input to include a page and you fail to validate them.
-
It's only insecure if you're allowing user input to include a page, in which case, there is a number of ways to verify the page is valid.. 1) Switches.. (Quick and easy for small numbers of pages) if( isset( $_GET['page'] ) ) { switch( $_GET['page'] ) { case 'page1': include( 'path/to/page1.php' ); break; case 'page2': include( 'path/to/page2.php' ); break; default: include( 'index.php' ); } } 2) List the valid pages in an array... if( isset( $_GET['page'] ) ) { $pages = array( 'page1', 'page2', 'page3' ); if( in_array( $_GET['page'], $pages ){ include( $_GET['page'] .'.php' ); } else { include( 'index.php' ); } } 3) The file_exists way.. Put all pages that are allowed to be included by user input into a seperate dir.. if( isset( $_GET['page'] ) ) { if( file_exists( 'path/to/allowed/pages/'. $_GET['pages'] .'.php' ) { include( 'path/to/allowed/pages/'. $_GET['page'] .'.php' ); } else { include( 'index.php' ); } } Does this clear up your confusion? Includes/Requires are a very important part of PHP. As I said, they're only insecure if you do not validate a page which is being called in via user input, or by placing the page to include as a param in the web address. (example.com?page=pagename) :thumbup:
-
I know :) I just posted the one I use for reference.. Obviously, if your project is open source or you have a team it's good to have all the extra checks, but I rarely need to find areas so I left it bare bones :thumbup: Glad someone paid attention in school. ^^
-
<?php function areaOfCircle( $radius ){ return number_format( pi() * $radius * $radius, 2 ); } echo areaOfCircle( 10 ); // 314.15 ?> Enjoy :) Edit: Not sure about circumference, never paid attention during that..
-
Idea for MWG: Introductions
LordDan replied to Dillion & Amanda 4 Lif's topic in Feedback and Site Support
I've used WoltLab forums before and there is a plug-in to display a pop-up message the first time a newly registered user logs in, that'd be perfect for what your saying and this way it wont be a permanent message we all have to look at. -
Idea for MWG: Introductions
LordDan replied to Dillion & Amanda 4 Lif's topic in Feedback and Site Support
I wasn't too sure when I first arrived, I just assumed Chit Chat would be the most suitable place, so I do agree with an Into thread ^^