Jump to content

ypirc

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Everything posted by ypirc

  1. Alternatively, you could use the "time" bin and not the bash "builtin" command.  The benefit of this is that it has a  "format" flag that you can pass to _only_ return what you want. [quote] # /usr/bin/time -f "%S" ls >/dev/null 0.00 [/quote]
  2. It has nothing to do with your PHP code. You either have to A) Allow relaying from localhost or b) Change or allow the e-mail address you have in your "From" address. This is an server administration issue, not PHP.
  3. You are missing some brackets... $_POST[$row[address] should be $_POST[$row[address]] and $_GET[$row[id] should be $_GET[$row[id]]
  4. After the last quote should be a period, not a comma.
  5. Why don't you look into Google Maps API [a href=\"http://www.google.com/apis/maps/\" target=\"_blank\"]http://www.google.com/apis/maps/[/a]
  6. php has csv commands [a href=\"http://us2.php.net/manual/en/function.fgetcsv.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.fgetcsv.php[/a] Also, MySQL has a function to import a full table from a csv file...check out this reference using the LOAD DATA FROM INFILE [a href=\"http://dev.mysql.com/doc/refman/5.0/en/load-data.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/load-data.html[/a]
  7. Give us sample data, expected output, and the query you are currently using that is giving you unexpected output.
  8. No, why delete the city and state if you delete a company? It's better just to maintain the data for future use. Also, you don't _need_ the cities to be unique if they are from different states. You can add duplicate city names for different states and it will still function correctly.
  9. [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] LENGTH(column) [color=green]FROM[/color] [color=orange]table[/color] [!--sql2--][/div][!--sql3--] OR [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] CHAR_LENGTH(column) [color=green]FROM[/color] [color=orange]table[/color] [!--sql2--][/div][!--sql3--] From: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/string-functions.html[/a] [quote] CHAR_LENGTH(str) Returns the length of the string str, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. CHARACTER_LENGTH(str) CHARACTER_LENGTH() is a synonym for CHAR_LENGTH(). [/quote
  10. You probably need to remove the first slash and make it "images/hand" instead. Also, you may look into using the full path, NOT the "url". Also, I suggest this function [a href=\"http://www.php.net/glob\" target=\"_blank\"]http://www.php.net/glob[/a]
  11. $_SERVER['HTTP_REFERER'] [a href=\"http://us3.php.net/reserved.variables\" target=\"_blank\"]http://us3.php.net/reserved.variables[/a]
  12. You don't format text design with PHP. You do that with HTML or CSS.
  13. [code] $name = $_POST['Name']; $address = $_POST['Address']; $color = $_POST['Color']; [/code] ?
  14. Not Found The requested URL /csys/files/classes/user.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
  15. Did you 'echo $function();' ?
  16. This is what I came up with. There are a several solutions. [code] *** Came up with a different solution than before... <? $file = file('/etc/passwd'); shuffle($file); for($i=0;$i<5;$i++) printf("%s\n", trim($file[$i])); ?> [/code]
  17. Well, at first you said the name was todays_image, and I looked and saw it says todays_girl. Also, I didn't realize there were extra parameters in the img tag. Use this: [code] preg_match('#(?<=<img src="/todays_girl/girls/).+\.jpg(?=")#i', $url, $matches); [/code] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] %php -f test.php Array ( [0] => rachel_nichols/gfd_med.jpg ) [/quote]
  18. That looks like a MySQL timestamp, so if it is, you should format it within MySQL. You can do this with the following: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html[/a] [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]mysql[color=orange]>[/color] [span style=\'color:blue;font-weight:bold\']SELECT[/span] DATE_FORMAT(NOW(), [color=red]'%M %Y'[/color]); [color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color] | DATE_FORMAT(NOW(), [color=red]'%M %Y'[/color]) | [color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color] | April 2006 | [color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color] 1 row [color=green]in[/color] set (0.00 sec) [!--sql2--][/div][!--sql3--] Replace NOW() with the name of your date column.
  19. Nevermind ... I see what you are asking now.
  20. Unfortunately, unix timestamping (which is what the methods previously stated use) does not work for people who were born before January 1, 1970. I just wrote this quick solutions..it's not perfect and expects the input to be "mm/dd/YYY". [code] <? $date = '05/25/1966'; $dex = explode('/', $date); $years = date('Y') - $dex[2]; $days = date('d') - $dex[1]; $months = date('m') - $dex[0]; if($months < 0) {         $years--;         $months+=12; } if ($days < 0) {         $days+=date('t', mktime(24,0,0,$dex[0],0,2006)); } printf("You are %s years, %s months, %s days old\n", $years, $months, $days); ?> [/code] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] %php -f age.php You are 39 years, 11 months, 24 days old [/quote]
  21. I altered your regex a bit...first of all in the 'example' you provided it was called todays_image and in the regex you use todays_girl ... Also you are escaping the '+' sign when infact you should be escaping the period, I also fixed a problem you were having with '()', anyway...hope this helps, the rest of your code looks like it should work, however, if you provide us the actual link so we can check it out, we might be able to form a better regex. I'm attaching the modified version of your regex...and then another one that I made seperately that uses look behind/ahead assertions.. [code] fixed version of yours: preg_match("#<img src=\"/todays_image/girls/([a-zA-Z_0-9]+/[a-zA-Z_0-9]+\.jpg)#i",$url, $matches); look ahead/behind assertions: preg_match('#(?<=<img src="/todays_image/girls/).+\.jpg(?=">)#i', $url, $matches); Note: in the look ahead/behind assertion you use $matches[0] not $matches[1] [/code]
  22. [a href=\"http://us3.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://us3.php.net/manual/en/features.file-upload.php[/a] [a href=\"http://us3.php.net/manual/en/function.is-uploaded-file.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.is-uploaded-file.php[/a] [a href=\"http://us3.php.net/manual/en/function.move-uploaded-file.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.move-uploaded-file.php[/a] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] The contents of $_FILES from the example form is as follows. Note that this assumes the use of the file upload name userfile, as used in the example script above. This can be any name. $_FILES['userfile']['size'] The size, in bytes, of the uploaded file. [/quote]
  23. Why don't you just require the class file and call it like you would any other time? Remember, classes are meant to be objects, you don't need to pass things around like that. For instance, let's assume a test authentication script...without actual code of course. [code] require 'sql.php' <blah blah blah> $sql = new sql(); $sql->function('hey'); OR ... if you decide to do your classes using the scope resolution operator, you'd do it like this: require 'sql.php' <blah blah blah> SQL_CLASS_NAME::function('hey'); [/code] Does that help ?
  24. [a href=\"http://en.wikipedia.org/wiki/Referer\" target=\"_blank\"]http://en.wikipedia.org/wiki/Referer[/a]
  25. Okay, you wouldn't use a switch statement for this. Also, you wouldn't seperate -each- student into a different variable. They'd normally probably be stored in an array, or be looped one-by-one from a database connection. I'm not going to explain switches here, but would prefer if you read and reviewed the examples at [a href=\"http://www.php.net/switch\" target=\"_blank\"]http://www.php.net/switch[/a] Here is how to perform this task using an if/else format. [code] <?   $grade = 70; $student = array('parker'=>'63', 'dave'=>'93', 'jessy'=>'63', 'walton'=>'96', 'david'=>'53'); foreach($student as $name => $mark) {         if ($mark < $grade) {                 echo "$name failed with a $mark\n";         }         else {                 echo "$name passed with a $mark\n";         } } ?> [/code] Output: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] %php -f c.php parker failed with a 63 dave passed with a 93 jessy failed with a 63 walton passed with a 96 david failed with a 53 [/quote]
×
×
  • 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.