Jump to content

Joe Haley

Members
  • Posts

    103
  • Joined

  • Last visited

    Never

Everything posted by Joe Haley

  1. return halts excecution of a function and returns the specified value, so: [code=php:0] function foo() {     echo 'a';     return false;     echo 'b'; } foo(); [/code] would simpyl echo 'a', as once the function returns, the rest of the code within it is not executed. You could assign the value of $i to a variable, like so: [code=php:0] $string = $string . ' ' . $i; [/code] (.= is equivilent to $string = $string . $i) And then return $string.
  2. http://ca.php.net/manual/en/ini.core.php#ini.sect.file-uploads Look for .htaccess on google. both those directives can be controlled via a .htaccess file
  3. Not if you havnt implemented custom session save handlers. Read the PHP manual for more information on sessions.
  4. I would use an external CSS stylesheet, and external script. thus only 2 lines need to be in the header, and the browser may cache the data for faster loading times.
  5. It is possable. http://cssplay.co.uk/menus/index.html Many examples of neat CSS menus. (including ones similar to that which you describe.)
  6. Personally, i use the following structure for language constructs: [code=php:0] if (condition) // space between if and (condition) { // on their own lines     // 4 spaces, or 1 tab at 4 space widths     echo 'hi'; } [/code] As for comments, use them. lots of them. and look at PHPDocumenter for generating HTML pages based on formated comments (http://www.phpdoc.org/) For comments, it is most important to explain WHY you are doing something, then simply stating what you are doing. Also, i never exclude curly brackets. even when i can. i find my code is a bit more readable that way [code=php:0] if(condition)     print('hi'); // i would do: if (condition) {     print('hi'); } [/code] mind you, these are only my personal preferances. do what looks best to you. But remember: Use the SAME coding-stlye, dont change halfway throgh. (this can lead to verry messy code)
  7. [code=php:0] echo <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace! END; [/code] Will also work. (from the PHP manual)
  8. I would start off with learning the basic concepts of programing (if you alredy do not know them) From there, learn basic PHP syntax. (the manual is verry helpfull, http://php.net ) From there, learn some advanced programing concepts (sessions, sql, ext) From there, learn Object Orentation. From there, learn as many basic functions as you can. (again, the manual) From there, learn as much as you can about the advanced functions. From there, program something big! =)
  9. I do belive one of those options allows you to search only your site. if not, then just force a google search with a site: paramiter.
  10. Do you mean passing variables via the get method in a hyperlink? If so: echo '<a href="page2.php?var=' . $val . '">'; On page2.php: $_GET['var'] would contain the value of $val.
  11. [quote author=thorpe link=topic=101694.msg402674#msg402674 date=1153758938] Use || [/quote] I would use a switch. (easyer to read and expand)
  12. [quote author=DaveLinger link=topic=101662.msg402665#msg402665 date=1153758585] why couldn't you use external apps? As long as they are installed on the server and are usable from php... [/quote] because the screen he wishes to capture is within a SWF running on a clients machine. He esentally needs a way to make flash take a picture of itself, and send it to PHP.
  13. [code] 2004-10-20 15:33:12 0123456789012345678[/code] [code=php:0]<?php $a = substr($date1, 5, 2); //days (or is it months? i suck with date formats) of date 1 $b = substr($date2, 5, 2); //days (months?) of date 2 ?>[/code] FYI: The key in the code block shows you the 'number' of charicters. '10-20' starts at offset 5, and has a length of 5. Also, the 'type' of $a and $b is [u]String[/u], [b]not[/b] [u]Integer[/u].
  14. http://www.google.com/intl/en/services/websearch.html Google has some interesting options.
  15. are cookies enabled in your browser? is the value of $username false?
  16. You wouldnt. You would use fread to get the entier file. Then, you would use other functions to find and replace part of it. then, you would use fwrite to write the modified file.
  17. If someone gets a users password (after having been hashed), its _EASY_ to find a collision for it. (allowing them to log in as that user) If someone gets a users password (after having been salted, then hashed), they may find a collision, but it will do them little good unless they can also get the salt, and algorythum used to hash the password.
  18. 0 as a timestamp is equil to January 1 1970 00:00:00 GMT So setting a cookie that expired isnt going to have the result you want ;) http://php.net/manual/en/function.time.php
  19. fread($handle, filesize($filename)) where $filename is the name of the file you opend with fopen. To write a slightly modified version of the file, open it with the proper mode, manipulate the string returnd by fread however you want, and then write it back into the file (or even write it to a diffrent file)
  20. [quote author=n8w link=topic=101570.msg402211#msg402211 date=1153694537] but does timestamp change to the current time everytime the record is modified [/quote] [quote] TIMESTAMP[(M)] A timestamp. The range is '1970-01-01 00:00:00' to partway through the year 2037. A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation. By default, the first TIMESTAMP column in a table is automatically set to the date and time of the most recent operation if you do not assign it a value yourself. You can also set any TIMESTAMP column to the current date and time by assigning it a NULL value. Variations on automatic initialization and update properties are described in Section 11.3.1.2, “TIMESTAMP Properties as of MySQL 4.1”. In MySQL 4.1, TIMESTAMP is returned as a string with the format 'YYYY-MM-DD HH:MM:SS'. Display widths (used as described in the following paragraphs) are no longer supported; the display width is fixed at 19 characters. To obtain the value as a number, you should add +0 to the timestamp column. In MySQL 4.0 and earlier, TIMESTAMP values are displayed in YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD, or YYMMDD format, depending on whether M is 14 (or missing), 12, 8, or 6, but allows you to assign values to TIMESTAMP columns using either strings or numbers. The M argument affects only how a TIMESTAMP column is displayed, not storage. Its values always are stored using four bytes each. From MySQL 4.0.12, the --new option can be used to make the server behave as in MySQL 4.1. Note that TIMESTAMP(M) columns where M is 8 or 14 are reported to be numbers, whereas other TIMESTAMP(M) columns are reported to be strings. This is just to ensure that you can reliably dump and restore the table with these types. Note: The behavior of TIMESTAMP columns changed considerably in MySQL 4.1. For complete information on the differences with regard to this data type in MySQL 4.1 and later versions (as opposed to MySQL 4.0 and earlier versions), be sure to see Section 11.3.1.1, “TIMESTAMP Properties Prior to MySQL 4.1”, and Section 11.3.1.2, “TIMESTAMP Properties as of MySQL 4.1”. [/quote] Via: http://dev.mysql.com/doc/refman/4.1/en/date-and-time-type-overview.html
  21. or place $hits++; on the line before the query.
  22. http://www.regular-expressions.info/ There are many, many great places to learn about regular expressions. Try reading up on em, theyre quite usefull.
  23. Personally, i would run it once, and modify the code that allows them to edit their signatures to check for image size (thus eliminating the need for an intensive cron)
  24. Personally, i suggest storing all times and dates as timestamps, then formating them for display. This eliminates the need for more complex comparisons, and allows you to re-format the date for display in any fasion you wish.
  25. There is probobly a way to optamise it, but, heck, going throgh EVERY user in a databse (even a few hundred) is an intesive task. You could always ignore user abort and not worry how long it takes, if you only intend to run it every once in a while. http://php.net/manual/en/function.ignore-user-abort.php
×
×
  • 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.