Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. If each of the artist names is on a seperate line in the file, why not use the file function: http://www.php.net/file Or, use file_get_contents, then explode the string on the seperating character to create the array. http://www.php.net/file_get_contents
  2. Depends on your network...my home network, with 4 computers and little traffic I could probably get a 50 - 60 MB file in the default 30 seconds.  At work, where there's 3000+ computers on the network, probably more like 20-25.
  3. change the name to something like "selectbox[]".  This will create a subarray in the $_POST superglobal.
  4. Your script may be timing out...100MB takes a while to upload, even on an intranet.  You may need to adjust the script run time.
  5. [quote author=Petsmacker link=topic=115710.msg471205#msg471205 date=1164077236] No way to convert it back? [/quote] See my above post.
  6. Try Gallery: http://gallery.menalto.com/
  7. have you tried strtotime? http://www.php.net/strtotime if it won't work "out-of-the-box", you may just have to rearrange the parts a little: [code]function convert($date) { //format: "Nov 13, 2006, 10:06pm"; //eliminate commas and seperate the parts $date = explode(" ", str_replace(",", "", $date)); //determine am / pm, remove the text, adjust the hours if necessary if (substr($date['3'], -2, 2) == "pm") { list($hour, $minute) = explode(":", rtrim($date[3], 'pm'); $hour += 12; } else { list($hour, $minute) = explode(":", rtrim($date[3], 'am'); } //reconstruct and pass to strtotime return strtotime($date[2] . "-" . $date[0] . "-" . $date[1] . " " . $hour . ":" . $minute); }[/code]
  8. If you want to post to another page a much easier way read this page: http://us2.php.net/manual/en/wrappers.http.php#AEN271674 It uses only three functions, and none of them have to do with the much more difficult cURL.
  9. In addition to how Nicklas has to print a true/false return you could use this: [code]if (strpos('Hello', 'lo') === TRUE) {   echo 'True'; } else {   echo 'False'; }[/code] The way that Nicklas has the if statement, if it returns Zero (as in the string was found at position zero) it would not evaluate to true.  This is because PHP will intrepret 0 and FALSE the same, unless you use the === and !== operators to force it to compare value and type.
  10. Try this: [code]<?php if ($_POST['action'] == "add") { $dirpath = "./"; $gallery_id = $_POST['gal_id']; $html = ""; foreach ($_FILES['photo'] as $key => $value) { $tmp_filename = $value['tmp_name']; //__ photos in dir ablegen _______________________________________ $src = imagecreatefromjpeg($tmp_filename); list($width,$height) = getimagesize($tmp_filename); $newwidth = 550; $newheight = ($height / $width) * $newwidth; $tmp = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $filename = $dirpath . $gallery_id . "/" . $value['name']; imagejpeg($tmp, $filename, 100); imagedestroy($tmp); #__ thumb _________________________________________________________ $srcthumb = imagecreatefromjpeg($tmp_filename); list($widththumb,$heightthumb) = getimagesize($tmp_filename); $newwidththumb = 100; $newheightthumb = ($heightthumb / $widththumb) * $newwidththumb; $src_top = ($src_height / 2) - ($dst_height / 2); $src_left = ($src_width / 2) - ($dst_width / 2); $tmpthumb = imagecreatetruecolor($newwidththumb, $newheightthumb); imagecopyresampled($tmpthumb, $srcthumb, 0, 0, $src_top, $src_left, $newwidththumb, $newheightthumb, $widththumb, $heightthumb); $thumbname = $dirpath . $gallery_id . "/zth_" . $titlesuf . $value['name']; //WTF is $titlesuf? imagejpeg($tmpthumb, $thumbname, 100); imagedestroy($srcthumb); imagedestroy($tmpthumb); #___________________________________________________________________imagedestroy($src); $title = mysql_real_escape_string($_POST['title'][$key]); $description = mysql_real_escape_string($_POST['description'][$key]); $sql = "INSERT INTO $gal_photos (gal, photo, title, description) VALUES ('$gallery_id','" . $value['name'] . "', '$title', '$description')"; $query = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error()); if (mysql_affected_rows($query) > 0) { $html .= ' <div> <span class="result">New Photo successfully added!</span><br /> <img src="../galleries/' . $gal . '/zth_' . $photo . '" /> </div>'; } } } elseif ($_GET['action'] == "listforms") { $query = "SELECT * FROM $gal_galleries ORDER BY id DESC"; $result = mysql_query($selgal_sql) or die ("Unable to select data.<br />" . $selgal_sql . "<br />" . mysql_error()); if (mysql_num_rows($result) > 0) { $gallery_select = " <select name='gal_id[]'>"; while ($row = mysql_fetch_array($result)) { $gallery_select .= ' <option value="' . $row['id'] . '">' . $row['id'] . ': ' . $row['title'] . '</option>'; } $gallery_select .= " </select>"; } else { $gallery_select = "<a href='gal_galleries.php'>Please create a new gallery to post photos!</a>"; } $html = ' <strong>Post New Photos</strong> <br /><br /> <form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="649760" />'; for ($x = 0; $x < $_GET['num']; $x++) { $y = $x + 1; $html .= ' <div class='uploadbox'>Associated Gallery ' . $y . ': <br /> ' . $gallery_select . ' <br /><br /> Photo File ' . $y . ':<br /> <input type="file" name="photo[' . $x . ']" size="50" /> <br /><br /> Photo Title ' . $y . ':<br /> <input type="text" name="title[' . $x . ']" size="50" /> <br /><br /> Photo Description ' . $y . ':<br /> <textarea cols="45" rows="5" name="description[' . $x . ']"></textarea> </div> <br />'; } $html .= ' <br /><br /> <input type="submit" name="action" value="add" /> </form>'; } else { $html = ' <strong>Post New Photos</strong> <br /><br /> <form action="' . $_SERVER['PHP_SELF'] . '" method="get"> <input type="hidden" name="action" value="listforms" /> <label for="num">Select number of photos to post</label>: <select id="num" name="num"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <input type="submit" value="Proceed" /> </form>'; } echo $html; ?>[/code]
  11. [code]$time1 = strtotime("10/08/2006 11:00:00"); $time2 = strtotime("10/02/2006 12:00:00"); echo round(($time1 - $time2) / 86400, 2) . " Days Between Dates";[/code] Adjust the division (the 86400) for different time spans to get hours and so on.  You could also break it out to days, hours, minutes, seconds by dividing and taking the remainder if you wanted.
  12. Your text file looks very much like xml.  If it is, just use an xml library to parse it into an array...I recommend minixml.
  13. To use only PHP: [code]header("location: nextpage.php");[/code] Javascript: [code]<?php echo '<script type="text/javascript">window.location.href = "nextpage.php";</script>[/code] Or use a meta refresh tag with a time of 0;
  14. is your function, GreetDay, returning the value "welcome, today is Monday", or is it echoing out that value?  The way that you are using it, you need to have it return a value. [code]function GreetDay() {   return "Welcome, today is " . date('l'); }[/code] not: [code]function GreetDay() {   echo "Welcome, today is " . date('l'); }[/code]
  15. Did you install the extension from PECL? [quote]PHP 4 Bundled The initial version is bundled in PHP 4 and is available in PECL as version 1.0, see http://pecl.php.net/package/zip. It can only read Zip Archives. This version uses the functions of the ZZIPlib library by Guido Draheim. You need ZZIPlib version >= 0.10.6. PECL and PHP 5.2 or later The newest version is bundled in PHP 5.2.0 or later and available in PECL, as version 1.1.0 or later. It does not require any external library. It can read and write Zip archives when used with PHP 5.1 or later and can only read them when used with PHP4. [/quote]
  16. [code]$filename = "path/to/file.txt"; $file = file($filename); $data = array(); foreach ($file as $line) {   $data[] = explode("|,|",$line); } echo '<pre>'; print_r($data); echo '</pre>';[/code]
  17. You need to put something for the value attribute...or I think just removing it will cause it to default to the text in the option. [code]<select amount ="amount"> <option>Amount</option> <option value="One">One </option> <option value="Two">Two </option> </select>[/code]
  18. means that your query failed...put "or die(mysql_error())" on the end of your mysql_query line. [code]$result = mysql_query("SELECT * FROM tablename") or die(mysql_error());[/code]
  19. Not with php, at least the client side portion is not php.  I would have to be javascript. You can either load all of the values into javascript variables then manipulate the display based on selections, or you can use AJAX and some server side processing to generate html to replace portions of the page with.
  20. http://www.phpfreaks.com/tutorials/40/0.php
  21. The only way to do this might be by using COM, however, I doubt it's possible. http://www.php.net/COM
  22. create a multidimensional array...each element contains a subarray that contains all of your items...then just serialize it and save it to the file. [code]<?php $formresults = unserialize(file_get_contents("formresults.dat")); $formresults[$clientname_or_some_other_identifier] = $_POST; $open = fopen("formresults.dat", 'w'); fwrite($open, serialize($formresults)); fclose($open); ?>[/code]
  23. It is, without a doubt, at best - a guess by php using the mysql_field_type function.  MySQL has several data types...like int, tinyint, bigint, and so forth...that mysql_field_type will generalize into one...in the listed examples, they area all listed as "int". Here is the exact C code from the php source code: [code]switch(field_type) { case FIELD_TYPE_STRING: case FIELD_TYPE_VAR_STRING: return "string"; break; #ifdef MYSQL_HAS_TINY case FIELD_TYPE_TINY: #endif case FIELD_TYPE_SHORT: case FIELD_TYPE_LONG: case FIELD_TYPE_LONGLONG: case FIELD_TYPE_INT24: return "int"; break; case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: case FIELD_TYPE_DECIMAL: #ifdef FIELD_TYPE_NEWDECIMAL case FIELD_TYPE_NEWDECIMAL: #endif return "real"; break; case FIELD_TYPE_TIMESTAMP: return "timestamp"; break; #ifdef MYSQL_HAS_YEAR case FIELD_TYPE_YEAR: return "year"; break; #endif case FIELD_TYPE_DATE: #ifdef FIELD_TYPE_NEWDATE case FIELD_TYPE_NEWDATE: #endif return "date"; break; case FIELD_TYPE_TIME: return "time"; break; case FIELD_TYPE_SET: return "set"; break; case FIELD_TYPE_ENUM: return "enum"; break; #ifdef FIELD_TYPE_GEOMETRY case FIELD_TYPE_GEOMETRY: return "geometry"; break; #endif case FIELD_TYPE_DATETIME: return "datetime"; break; case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: case FIELD_TYPE_BLOB: return "blob"; break; case FIELD_TYPE_NULL: return "null"; break; default: return "unknown"; break;[/code] As you can see, it is a guess.  The only way to get a 100% accurate answer as to what type of field it is is to use "SHOW COLUMNS FROM tablename" and see what the "type" column in the result contains. If you still don't beleive me, use this SQL: [code]CREATE TABLE `proof` (   `a` varchar(255) default NULL,   `b` tinyint(4) default '0',   `c` text,   `d` date default NULL,   `e` smallint(6) default '0',   `f` mediumint(9) default '0',   `g` int(11) default '0',   `h` bigint(20) default '0',   `i` float default '0',   `j` double default '0',   `k` decimal(10,0) default '0',   `l` datetime default NULL,   `m` timestamp NULL default NULL,   `n` time default NULL,   `o` year(4) default NULL,   `p` char(255) default NULL,   `q` tinyblob,   `r` tinytext,   `s` blob,   `t` mediumblob ) ENGINE=InnoDB DEFAULT CHARSET=latin1;[/code] Once you have that table in your db, execute this php code: [code]$conn = mysql_connect("hostname", "username", "password"); mysql_select_db("dbname"); $query = "SELECT * FROM proof"; $result = mysql_query($query); $fields = mysql_num_fields($result); $rows  = mysql_num_rows($result); $table  = mysql_field_table($result, 0); echo "<pre>Your '" . $table . "' table has " . $fields . " fields and " . $rows . " record(s)\n"; echo "The table has the following fields:\n"; for ($i=0; $i < $fields; $i++) {   $type  = mysql_field_type($result, $i);   $name  = mysql_field_name($result, $i);   $len  = mysql_field_len($result, $i);   $flags = mysql_field_flags($result, $i);   echo $type . " " . $name . " " . $len . " " . $flags . "\n"; } $query = "SHOW COLUMNS FROM proof"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { print_r($row); }[/code] Which will return: [code]Your 'proof' table has 20 fields and 0 record(s) The table has the following fields: string a 255 int b 4 blob c 65535 blob date d 10 binary int e 6 int f 9 int g 11 int h 20 real i 12 real j 22 unknown k 11 datetime l 19 binary timestamp m 19 unsigned zerofill binary time n 8 binary year o 4 unsigned zerofill string p 255 blob q 255 blob binary blob r 255 blob blob s 65535 blob binary blob t 16777215 blob binary Array (     [Field] => a     [Type] => varchar(255)     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => b     [Type] => tinyint(4)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => c     [Type] => text     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => d     [Type] => date     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => e     [Type] => smallint(6)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => f     [Type] => mediumint(9)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => g     [Type] => int(11)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => h     [Type] => bigint(20)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => i     [Type] => float     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => j     [Type] => double     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => k     [Type] => decimal(10,0)     [Null] => YES     [Key] =>     [Default] => 0     [Extra] => ) Array (     [Field] => l     [Type] => datetime     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => m     [Type] => timestamp     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => n     [Type] => time     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => o     [Type] => year(4)     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => p     [Type] => char(255)     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => q     [Type] => tinyblob     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => r     [Type] => tinytext     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => s     [Type] => blob     [Null] => YES     [Key] =>     [Default] =>     [Extra] => ) Array (     [Field] => t     [Type] => mediumblob     [Null] => YES     [Key] =>     [Default] =>     [Extra] => )[/code]
  24. Your software could be doing a lot of things with the xml files...it could be generating them to store data, they could be used to store user settings for example.  It may use XSL to display data back to you.  The creator could have used the xml files in place of a database if he/she wanted.
×
×
  • 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.