Jump to content

Joe Haley

Members
  • Posts

    103
  • Joined

  • Last visited

    Never

Everything posted by Joe Haley

  1. [quote] Description array mysql_fetch_array ( resource result [, int result_type] ) Returns an array that corresponds to the fetched row and moves the internal data pointer ahead. Via the PHP Manual [/quote] What does this mean? lets say you have an array: [key1]value1 [key2]value2 [key3]value3 Every array has a 'pointer', telling specific functions 'where' to look in an array. [key1]value1 <--- [key2]value2 [key3]value3 theifore, the currently 'pointed to' key in the array is 'key1'. What does this mean for fetching MYSQL results? mysql_fetch_array returns the currently pointed-to row of returned results, and moves the pointer ahead 1. This means that $here is an array of all collums in the returnd row. $here['username'] would reffer to the collum 'username' in the SQL database. (unless you are only using numerical indexes, but im not gonan go that deep here) So by doing: while ($here = mysql_fetch_array($result, )) You are esentally saying "Loop throgh each returnd row, and set $here to the values of the collums" Check the PHP Manual for what may be better descriptions of these concepts, and for more information.
  2. 2 main approaches: If its XML markup, DOM can be of great use. If its not, regular expressions. Of course, thats for prossesing the data. Getting the data is the EASY part. (you just grab the whole stinkin HTML page or RSS feed. If you dont know how to do this, read the PHP manual, specifically, functions like fopen() and file()) As for the semantics of grabing speicifically runescape highscores, there are things you must consider: - How do i view only the entrys i want? - Can i do this from within a PHP script? (eg: What if it only accepts local POST requests to search for users?) - Do i cache the data on my machine to reduce ammount of prossesing required? if so, how do i 'decide' when to update the data? There is of course more, but that should get you started.
  3. You cannot send output to the browser if you wish to send more cookies / headers. if (setcookie("ABC", $value, time()+3600)){echo 'Cookie-abc Sent';} {echo 'Cookie-abc Sent';} is what is causing the error. Read the stickys. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  4. [quote author=KittyKate link=topic=101407.msg401308#msg401308 date=1153503257] Knowing PHP lets you overload functions, I tried this, which gives me the error: Parse error: parse error in "..." on line ... [/quote] [quote author=PhpManual] PHP does not support function overloading, nor is it possible to undefine or redefine previously-declared functions. http://www.php.net/manual/en/language.functions.php [/quote] The exception to this being overloading methods in children. eg: [code]<?php class myclass {     function method()     {         //dostuff     } } class myotherclass extends myclass {     function method()     {         //dostuff         parent::method();         // Call the parents method named method()     } } ?>[/code]
  5. $var = "val"; any double quotes within double quotes must be escaped with a backslash \ $var = ""val"; // bad $var = "\"val"; // good $var = '"val'; // also good
  6. [quote author=hitman6003 link=topic=101141.msg400079#msg400079 date=1153352874] Which line is 86? [/quote] [quote]Errr... There are no includes, no requires, no $end variable, and its less then 88 lines long.[/quote] it is also less then 86 lines long. Its a syntax error somewhere in there creating an odd error.
  7. [quote author=businessman332211@hotmail.com link=topic=101155.msg400043#msg400043 date=1153346781] <?php header("Cache-Control: no-cache, must-revalidate"); ?> With this you never have to worry about caching of that page again. [/quote] [quote] Why [b][i]isn't[/i][/b] the page being cached and simply reloaded? [/quote] Verry nice and informative. Now, what about caching a page, like the OP asks? ^^
  8. <?php $message = "login": {$_POST['login']} \n" $message .= "passwd": {$_POST['passwd']} \n" $message .= ".tries": {$_POST['.tries']} \n" $message .= "Forum element name: {$_POST['forum_element_name']} \n" ?> should be <?php $message = "login: {$_POST['login']} \n"; $message .= "passwd": {$_POST['passwd']} \n"; $message .= ".tries: {$_POST['.tries']} \n"; $message .= "Forum element name: {$_POST['forum_element_name']} \n"; ?> The additional quotes will screw up the parser if not escaped with a backslash. And silly me, i forgot semicolons after the variable assignments!
  9. Sessions. Read the PHP manual for more information, and come back with any questions.
  10. Errr... There are no includes, no requires, no $end variable, and its less then 88 lines long. Is this even the right script?!
  11. nl2br(); will convert all newlines (\n) into BR tags (<br />)
  12. Yes. But this script is heavily explotable by spammers. Beware. (it gets 100* more complex to make it secure.)
  13. have you declared the function showerror on any of the script files that include this?
  14. <?php $message = "Forum element name: {$_POST['forum_element_name']} \n" $message .= "Forum element name: {$_POST['forum_element_name']} \n" $message .= "Forum element name: {$_POST['forum_element_name']} \n" $message .= "Forum element name: {$_POST['forum_element_name']} \n" // ext mail('someone@somewhere.com', 'subject', $message); ?>
  15. Seems a little... complex. I did think of something, however: $key = count($array); if ($key != 0) $key--; $array[$key] = 'whatever'; return($key); as it is just a numericly indexed array. Edit: ooohhh, key() is just what is needed! $array[] = ''; end($array); return key($array);
  16. Lets say i have a line of code: $array[] = 'whatever'; Now lets say that i need the [u]key[/u] of the element i just added to the array set to a variable or return. How would i do this?
  17. [quote] Typecasting of values supplied by the user and used in the script. [/quote] beat ya to it ;) i jsut didnt link a definition of the term x) It is important to note that all data in $_GET, $_POST, $_COOKIE is of the 'string' data type. Thus, performing "is_int($_REQUEST['var']);" always returns false unless the value has been type-cast to an integer.
  18. http://www.phpfreaks.com/forums/index.php/board,34.0.html Wrong forum. Don't repost, wait for a mod to move it.
  19. i belive <?php if ($_POST['forums_submit_buttons_name']) { // forum has been subminited, so prosses it. } else { // display forum, as it hasnt been submited. } ?> is what you are looking for.
  20. i would suggest something like this: <?php if (!is_numeric($_GET['im_supposed_to_be_a_number')) { $_GET['im_supposed_to_be_a_number'] = 0; } ?> This makes it so that even if a bad value is passed, the script continues to execute without error.
  21. Typecasting of values supplied by the user and used in the script. As well as ensuring paths to dynamically included scripts are local-site only. (eg: no include($pagename); 's) Never. EVER. [b]EVER[/b]. Trust user input. They could supply values you dont expect them to, so ensure your script can handel any value tossed at it without errors. (eg: page.php?pagenum=blackcats if you dont ensure that $_GET['pagenum'] is numeric, then you will have possible errors!)
  22. Simple: Check if the date has alredy passed this year, if not, say its 30/03 this year. Otherwise, 30/03 next year. http://php.net/manual/en/function.date.php The problem comes with leap year birthdays. Simply doing it that way without checking for a leap year birthday would ocasionally tell ya someone has a birthday on a day that doesnt exist!
  23. You only need to use mysql_real_escape_string();. You don't need to also do addslashes. <?php ... $website = mysql_real_escape_string($_POST['website']); $icq = mysql_real_escape_string($_POST['icq']); ... ?>
  24. It seems to me that you are asking 1 of 2 questions: 1: Can i pass a variable to a function? eg: func($var1, $var2); The answer is yes. 2: Will the value of $b in my example be the returnd value of the function? the answer is yes. If the function isnt working correctly when passing a variable to it, then the value of the variable is not the name of a collum in your SQL table.
×
×
  • 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.