Jump to content

wmbetts

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wmbetts's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hope this helps.. http://www.imperialized.net/view_image.php?id=5%20and%20MID(id,1,1)%20LIKE%20char(53) <== SQL Injection. -- will
  2. What's the poing of doing something like this $mysqli->query("select * from table")->fetch_assoc(); What's the point of that? Other then to make the code look horrible? Is there an actual benifit to it? Saving a couple lines really isn't worth it to me. Any input on why that is better then say $result = $mysql->query("select * from table"); $row = $result->fetch_array(); would be helpful.
  3. I would, but it wouldn't be for a Windows server. I don't belive chmod() works on windows and I'm not really sure what would, but I'll look into it.
  4. You're not really suppose to php actual PHP in a smarty template. Try moving your PHP outside of your template. I'm not really sure if that will help or not, but it's worth a try.
  5. If you would like a tutorial written on a PHP/MySQL topic please respond to this thread and let me know what you would want the tutorial to cover.
  6. echo "Flight request date: " . "$date = $flight['Dept Date']"; The above should never be done.... either $date = $flight['Dept Date']; echo "Flight request date: " . $date; or Flight request date: echo "Flight request date: " . $flight['Dept Date']; That said I would suspect you get output like the following: Let's assume $filght['Dept Date'] == "Sept 31 2007" The output would look like "Flight request date: = Sept 31 2007". This would happen because everything is enclosed in quotes. If you dropped the quotes around $date = $flight['Dept Date'] it would work right.
  7. Yes the second one does. It's a recursive function.
  8. <?php function get_list($dir) { static $arr = Array(); if (!array_key_exists($dir,$arr)) { $arr[$dir] = 0; } foreach(glob("${dir}/*") as $fn) { if (is_dir($fn)) { get_list($fn); } else { $arr[$dir] += 1; print $fn . "\n"; } } return $arr; } $a = get_list(getcwd()); print "\n\n"; foreach($a as $k => $v) { print "Number of files in ${k}: ${v} \n"; } ?> it will product output like : server1# php a.php /usr/home/will/php-mtg/a.php /usr/home/will/php-mtg/array.php /usr/home/will/php-mtg/core/a/a.php /usr/home/will/php-mtg/core/core.php /usr/home/will/php-mtg/count.php /usr/home/will/php-mtg/main.php /usr/home/will/php-mtg/menus/a/a/b.php /usr/home/will/php-mtg/menus/a/a.php /usr/home/will/php-mtg/menus/a/b.php /usr/home/will/php-mtg/time.php /usr/home/will/php-mtg/time1.php /usr/home/will/php-mtg/time2.php Number of files in /usr/home/will/php-mtg: 7 Number of files in /usr/home/will/php-mtg/core: 1 Number of files in /usr/home/will/php-mtg/core/a: 1 Number of files in /usr/home/will/php-mtg/menus: 0 Number of files in /usr/home/will/php-mtg/menus/a: 2 Number of files in /usr/home/will/php-mtg/menus/a/a: 1
  9. do you want total number of files and directories or total number of files in corresponding directories? /dir 2 files /dir/subdir1 3 files or Files: 100 Dir: 50
  10. <?php $original_array = Array("06:30","08:10","09:35","12:00","15:45","17:10","19:35"); array_walk($original_array, 'add_date'); /* add date function */ function add_date(&$item) { $iso_date = date('Y-m-d'); $item = "${iso_date} ${item}:00"; } print_r ($original_array); ?> or <?php $original_array = Array("06:30","08:10","09:35","12:00","15:45","17:10","19:35"); array_walk($original_array, create_function('&$item',' $item = date(\'Y-m-d\') . " " . $item; ')); print_r ($original_array); ?>
  11. I should have tested that better.... =\ sorry Here's a better version.. why is it better? it's smaller and actually works right. <?php function get_list($dir) { foreach(glob("${dir}/*") as $fn) { if (is_dir($fn)) { get_list($fn); } else { print $fn . "\n"; } } } get_list(getcwd()); ?>
  12. This doesn't tell you what files are in what directories, but it will count all directories and files. This ignores .. and . diectory listing (2 directories and 5 files): server1# ls -al total 18 drwxr-xr-x 4 root will 512 Jul 25 15:50 . drwxr-xr-x 47 will will 3072 Jul 25 11:00 .. -rw-r--r-- 1 root will 408 Jul 25 15:41 array.php drwxr-xr-x 2 root will 512 Jul 25 15:10 core -rw-r--r-- 1 root will 516 Jul 25 16:09 count.php -rw-r--r-- 1 root will 1571 Jul 25 15:01 main.php drwxr-xr-x 2 root will 512 Jul 25 15:08 menus -rw-r--r-- 1 root will 222 Jul 25 15:27 time.php server1# ls core/ core.php server1# ls menus/ server1# output: server1# php count.php Array ( [dir] => 2 [file] => 5 ) server1# code: <?php function count_stuff($dir) { static $arr = Array("dir" => "0" , "file" => "0"); if (($dh = @opendir($dir)) !== false) { while ($file = readdir($dh)) { if (is_dir($file)) { if (strstr($file,".") || strstr($file,"..")) { continue; } else { $arr["dir"] += 1; count_stuff($file); } } else { $arr["file"] += 1; } } } else { die ("Directory supplied is not a directory.\n"); } return $arr; } $a = count_stuff("/home/will/php-mtg/"); print_r($a); ?>
  13. I don't know if this is the best way to do this or if it's even what you want, but here ya go. <?php $date_time = Array("06:30","08:10","09:35","12:00","15:45","17:10","19:35"); function somename($array) { for ($i = 0; $i < sizeof($array); $i++) { $str = date("Y-m-d") . " " . $array[$i]; $array[$i] = $str; } return $array; } print "Output before function call: \n"; print_r($date_time); $date_time = somename($date_time); print "Output after function call: \n"; print_r($date_time); ?> output : Output before function call: Array ( [0] => 06:30 [1] => 08:10 [2] => 09:35 [3] => 12:00 [4] => 15:45 [5] => 17:10 [6] => 19:35 ) Output after function call: Array ( [0] => 2007-07-25 06:30 [1] => 2007-07-25 08:10 [2] => 2007-07-25 09:35 [3] => 2007-07-25 12:00 [4] => 2007-07-25 15:45 [5] => 2007-07-25 17:10 [6] => 2007-07-25 19:35 )
  14. <?php function display_time($scr) { $time = date("H:i:s"); ncurses_mvwaddstr($scr,25,75,$time); ncurses_wrefresh($scr); } $cur = ncurses_init(); $fs = ncurses_newwin(0,0,0,0); while (1) { display_time($fs); } ?> you just need to get ride of the ncurses_getch() call
×
×
  • 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.