Jump to content

litebearer

Members
  • Posts

    2,356
  • Joined

  • Last visited

Everything posted by litebearer

  1. perhaps use   [b] LIMIT 3[/b] day late dollar short :)
  2. just to push it a little more... our families can be looked at as multi-dimensional arrays $a[lastnames here][firstnames here][gender here][age here]
  3. hmmm, this may be of some help. http://www.nstoia.com/toh/technical/listdir/index.php It lists a folder's contents and can sort by name, date or size - ascending or descending - and make them clickable links Lite...
  4. Might be of some use... http://www.nstoia.com/toh/technical/imageresize/index.php Lite...
  5. Hmmm, looks like 'hammer time'... Maybe this may be of some use. (file name is letters.php) [code] <?PHP ######################## # set page number ######################## $this_is_page = 0; if(isset($_GET['what_page'])) { $this_is_page = $_GET['what_page']; }else{ $this_is_page = 0; } ########################################### # define what letters are in which group ########################################### $letters[0] = array ('a','b','c','d','e'); $letters[1] = array ('f','g','h','i','j'); $letters[2] = array ('k','l','m','n','o'); $letters[3] = array ('p','q','r','s','t'); $letters[4] = array ('u','v','w','x','y','z'); ########################## # get the info from the database # ordering on last name ########################## $db = mysql_connect("localhost", ""); mysql_select_db("lakeside_chamber"); $query = "SELECT * FROM members ORDER by Last_Name"; $result = mysql_query($query) or die(mysql_error()); ############################################## # loop thru the results # if the data is in the current letter group, display it ############################################### while($row = mysql_fetch_array($result)){ $findme = strtolower(substr($row['Last_Name'],0,1)); if(in_array($findme,$letters[$this_is_page])) { $this_record = $row['Company_Name'] . "<br>" . $row['Last_Name'] . ", " . $row['First_Name'] . "<br>"; $this_record = $this_record . $row['Address'] . "<br>" . $row['City'] . ", " . $row['State']. " " . $row['Zip_Code']; $this_record = $this_record . $row['Phone_Number'] . "<br>" . $row['City'] . ", " . $row['State']. " " . $row['Zip_Code'] . "<br>"; $this_record = $this_record . $row['Web_Email'] . "<br>" . $row['Web_Site_address']; echo $this_record ."<br><hr>"; } } ?> <!-- ################################# --> <!-- # display a menu for the different pages --> <!-- ################################## --> <a href="letters.php?what_page=0">View last names beginning with A - E</a><br> <a href="letters.php?what_page=1">View last names beginning with F - J</a><br> <a href="letters.php?what_page=2">View last names beginning with K - O</a><br> <a href="letters.php?what_page=3">View last names beginning with P - T</a><br> <a href="letters.php?what_page=4">View last names beginning with U - Z</a><br> <?PHP ?>[/code] Lite...
  6. look into using sessions http://codewalkers.com/tutorials/32/1.html Lite...
  7. this may help... http://www.nstoia.com/toh/technical/imageresize/index.php Lite...
  8. The scenario: 1. flatfile database       consists of records delimited by carriage returns.       records have fields delimited by commas       example of file structure and content: [quote]         1,Nicholas,,Stoia,6992 Biscayne,White Lake,MI,48383,1,13,1946,,,,,,,         2,Myles,Edward,Dean,,,WV,,0,0,0,,,,,,,         3,Sharon,Marie,Stoia,6992 Biscayne,White Lake,MI,48383,7,16,1955,,,,,,,         4,Jonathon,Hunter,Stoia,6992 Biscayne,White Lake,MI,48383,12,13,1988,,,,,,,         5,Rebecca,,Dean,,,WV,,0,0,0,,,,,,,         6,Gilbert,Rial,Stebbins,22600 Bluewater Drive,Macomb Twp,MI,48044,0,0,0,,,,,,,         7,Beverly,,Stebbins,22600 Bluewater Drive,Macomb Twp,MI,48044,0,0,0,,,,,,,         8,Sean,Michael,Dean,167 Weston Road,Wellesley,MA,02482,0,0,0,,,,,,, [/quote] 2. multidimensional array created as follows: [code]         // read file into array         $file = file("faf.txt");         $count = count($file);         // convert first array to multidimensional array         $i = 0;         for($i=0;$i<$count;$i++) {         $file_cards[$i] = explode(",", $file[$i]);         } 3. sort by last name (         function compare($x, $y){           if ( $x[3] == $y[3] )             return 0;           else if ( $x[3] < $y[3] )             return -1;           else             return 1;         }         usort($file_cards, 'compare'); [/code] The Question: The above works fine; however, in addition to sorting by last name [code]$file_cards[x][3] [/code] I would like to further sort by first name [code]$file_cards[x][1][/code] and then by middle name [code]$file_cards[x][2] [/code]. How? Thanks, Lite...
  9. numerous questions, BUT to help solve we need to see some code. (as to the sessions problem - have you started sessions at the top of every page?) Lite
  10. Might look here: http://instruform.com/wordconv.phps  and here: http://wvware.sourceforge.net/ Lite...
  11. As a start, you might search google for free real estate scripts. http://www.google.com/search?hl=en&q=php+free+real+estate+scripts Play with them, study them, take them apart and put them back together. It will give you a good handle on what you are trying to do and how to do it. Lite...
  12. Also from the manual [quote] The standard DES-based encryption crypt() returns the salt as the first two characters of the output. It also only uses the first eight characters of str, so longer strings that start with the same eight characters will generate the same result (when the same salt is used). [/quote] Which would seem to indicate that user:michaeljordan02 password: 123456789a  would ultimately give same result as user:michaeljordan99 password: 123456789bx3d Or will it? (too early to set up a test script, coffee has NOT kicked in yet) Lite...
  13. I know it seems too obvious, but when you have had people tell you their equipment will not work and that they have tried everything, only to get there and find its not plugged into the electrical socket... (1) make sure the pictures are actually being uploaded (2) make sure they are in the proper path (3) make sure they are of the accepted type (ie jpg, gif, png etc) Very difficult to solve a code problem without seeing the actual code. Lite...
  14. Hmmm, ok, a little more definition... First, I know that using mysql would simplify things; however, for various reasons, I am using a flatfile for this particular project. each line in the file represents a 'record' each record has several 'fields' user desires to search the file for all records that contain certain keywords user can use either 1, 2 or 3 keywords. user can select that either ALL or ANY of the keywords are in a record Matching using ANY is no brainer The code I previously posted will, in the end, accomplish the task. My basic question was/is:  Is there a more effective, simpler method of reaching the same end result Not sure if that makes it any clearer. Thanks, Lite...
  15. Evening, all... I can't seem to get my thoughts properly wrapped around this problem. Scenario: Searching an array of data for matches to keywords. Create a new array from the matches. 01. From 1 to 3 keywords possible. Match must have ALL keywords. 02. Case insensitive 03. $needle1, $needle2 and $needle3 represent the possible keywords 04. $old_haystack represents an element from the original array 05. $haystack represents lowercase version of $old_haystack 06. must be compatible with PHP versions 3, 4 and 5 I came up with this sledge-hammer approach, looping through all of elements of the original array and runing this function on each element. However, I am sure there is a more elegant, refined and effective approach, but what is it? [code] <?PHP function validate_words($needle1, $needle2, $needle3, $old_haystack) { $haystack = strtolower($old_haystack); $new_element = ""; $kwl[0] = strlen(trim($needle1); $kwl[1] = strlen(trim($needle2); $kwl[2] = strlen(trim($needle3); $add_element = 0; if(($kwl[0]>0) AND ($kwl[1]>0) AND ($kwl[2]>0) AND (substr_count($haystack, $needle1)>0) AND (substr_count($haystack, $needle2)>0) AND (substr_count($haystack, $needle3)>0)) { // add element to new array return 1; } if(($kwl[0]>0) AND ($kwl[1]>0) AND ($kwl[2]<1) AND (substr_count($haystack, $needle1)>0)  AND (substr_count($haystack, $needle2)>0)){ // add element to new array return 1; } if(($kwl[0]>0) AND ($kwl[1]<1) AND ($kwl[2]>0) AND (substr_count($haystack, $needle1)>0) AND (substr_count($haystack, $needle3)>0)) { // add element to new array return 1; } if(($kwl[0]>0) AND ($kwl[1]<1) AND ($kwl[2]<1) AND (substr_count($haystack, $needle1)>0)) { // add element to new array return 1; } if(($kwl[0]<1) AND ($kwl[1]>0) AND ($kwl[2]>0) AND (substr_count($haystack, $needle2)>0) AND (substr_count($haystack, $needle3)>0)) { // add element to new array return 1; } if(($kwl[0]><1) AND ($kwl[1]>0) AND ($kwl[2]<1) AND (substr_count($haystack, $needle2)>0)) { // add element to new array return 1; } if(($kwl[0]<1)  AND ($kwl[1]<1) AND ($kwl[2]>0) AND (substr_count($haystack, $needle3)>0)) { // add element to new array return 1; } return 0; } ?> [/code] Thanks, Lite...
  16. You could/should do a couple of things 1. use some string functions like trim, and/or strlen to make sure the variable contain data. 2. you could also check to make sure the variables only contain certain characters, ie alphanumeric 3. use a captcha to add a little more protection Lite...
  17. This might be of some help... http://www.nstoia.com/toh/technical/imageresize/index.php Lite...
  18. I would think that watermarking the thumbnail AFTER it is created would provide the best clarity of the watermark message. Text has a tendency to become very blurred when it is reduced AFTER it is created. (O's e's, a's, g's and r's end up with the 'loop' closing into a dot). Lite...
  19. Just a thought (or two).... (1) consider the real objective - presumably to prevent unauthorized use of an image. (2) realizing that your example ( 1024 x 1024  original to 120 x 120 thumb), is exactly that - an example, IF we were to create an image 1024 x 1024, it would take a watermark approximately 400 x 400 to have the mark be of sufficient size to 'protect' the image AND to still be visible when scaled down to 120 x 120. (3) re-evaluate the need for the thumb to be watermarked, it will have lost sufficient definition during the resizing process so as to make it unsuitable for enlarging. (4) re-evaluate the need for watermarking at all. If I so desperately wanted to 'steal' an image, it would take well under an hour to remove all traces of a watermark using readily available graphics software. (5) consider who might attempt to 'steal' your images.  one must remember laws protect all of us, and it is very easy to obtain a judgment against someone who has infringed upon our rights and property. HOWEVER, collecting on that judgement is extremely difficult and time consuming. Not to mention that although a court may agree that you have been 'injured';  the value of that 'injury' may be miniscule in the court's eyes. Just an old man's two cents. Lite...
  20. Sorry been in meetings all week. Let me work on this tonight and see if I can scratch together a solution for you. Lite...
  21. This might be of some help... http://www.nstoia.com/toh/technical/imageresize/index.php Lite...
  22. Check you inbox for a message
  23. Just another little 'tool' for your bag of tricks. This script will display the structure and data in a mysql database table. It is useful for checking (1) that you are using the proper values for connecting, (2) that the field names and types are what you think they are; and (3) for seeing if there is, in fact, data in the table. As an aside, it can also be used to create csv and/or excel files for downloading. The only items you need to change are in SECTIONS 1 & 2 Hope this is of some help in isolating your problem. [code]<?php session_start(); header("Cache-control: private");  // IE 6 Fix. session_unset(); ################################################################# # this small script can be used to # # get and display a database table's structure (field names and field type) # get and display the field contents in an html table # get and store the field names and contents to an excel file # ################################## # # SECTION 1 # # set the database variables # $database="#####"; $location = "#####";  $username = "#####";  $password = "#####";  $db_table = "#####"; ###################################### # # SECTION 2 # # set the function switches # 0 means use # 1 means do NOT use # $display_table_structure = 0; $display_table_contents = 0; $create_csv_file = 1; // use this to create a csv file from the data $create_excel_file = 1; // use this to create an excel file from the table // requires m_e.php $csv_name = $db_table . "_" . time(); // this gives the csv file a unique name $how_many = 10; // use this value to limit the number of records returned in the data query (0 means no limit) #################################################### #################################################### # # DO NOT EDIT BELOW THIS POINT # #################################################### #################################################### ###################################### # define the function(s) // This function gets the field names function my_db_get_table_field_names($table) { $sql = "SHOW COLUMNS FROM `$table`"; $field_names = array(); $result2 = mysql_query($sql); for($i=0;$i<mysql_num_rows($result2);$i++){ $row = mysql_fetch_array($result2); $name = $row['Field']; array_push($field_names, $name); } return $field_names; } ############################################ # connect to the database mysql_connect ($location, $username, $password); @mysql_select_db($database) or die( "Unable to select database"); $result0 = mysql_query("SHOW COLUMNS FROM $db_table"); if (!$result0) {   echo 'Could not run query: ' . mysql_error();   exit; } #################################################### # get the field names into an array and count them $new_array = my_db_get_table_field_names($db_table); $fields = count($new_array); ################################################### # get all the data and count the records if ($how_many == 0) { $result = mysql_query( "SELECT * FROM $db_table" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); }else{ $result = mysql_query( "SELECT * FROM $db_table LIMIT $how_many" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); } ############################################################## # display the general information echo "This information is for the " . $database . " database. Table " . $db_table . "<br><br>"; echo "There are " . $fields . " columns/fields  and " . $num_rows . " records.<br><br>"; ########################################################### # display the table structure if ($display_table_structure == 0) { echo "<hr>Table structure for " . $db_table . ": <br><br>"; echo "<table border=1> <tr><td>Field #</td><td>Field Name</td><td>Field Type</td></tr>"; $result9 = mysql_query("SHOW FIELDS FROM $database.$db_table"); $i = 0; while ($row = mysql_fetch_array($result9)){ echo "<tr><td>" . $i . "</td><td>" . $row['Field'] . "</td><td>" . $row['Type'] . "</td></tr>"; $i = $i +1; } echo "</table>"; } ############################################################## # display the table contents if ($display_table_contents == 0) { echo "<hr>Table data for " . $db_table . ": <br><br>"; print "<table width='100%' border=1>\n"; $i = 0; print "<tr>\n"; for ($i=0;$i<$fields;$i++) {   print "\t<td><font face=arial size=1/>$new_array[$i]</font></td>\n"; } while ($get_info = mysql_fetch_row($result)){ print "<tr>\n"; foreach ($get_info as $field) print "\t<td><font face=arial size=1/>$field</font></td>\n"; print "</tr>\n"; } print "</table>\n"; } ################################################## # do the excel file creation if ($create_excel_file ==0) { ?> <meta http-equiv="refresh" content="2;url=http://nstoia.com/m_e.php"> <?PHP } ?>[/code] and here is the script for the excel file [code]<?php //EDIT YOUR MySQL Connection Info: $DB_Server = "####"; //your MySQL Server $DB_Username = "####"; //your MySQL User Name $DB_Password = "####"; //your MySQL Password $DB_DBName = "####"; //your MySQL Database Name $DB_TBLName = "####"; //your MySQL Table Name //$DB_TBLName, $DB_DBName, may also be commented out & passed to the browser //as parameters in a query string, so that this code may be easily reused for //any MySQL table or any MySQL database on your server //DEFINE SQL QUERY: //you can use just about ANY kind of select statement you want - //edit this to suit your needs! $sql = "Select * from $DB_TBLName"; //Optional: print out title to top of Excel or Word file with Timestamp //for when file was generated: //set $Use_Titel = 1 to generate title, 0 not to use title $Use_Title = 1; //define date for title: EDIT this to create the time-format you need $now_date = date('m-d-Y H:i'); //define title for .doc or .xls file: EDIT this if you want $title = "Dump For Table $DB_TBLName from Database $DB_DBName on $now_date"; /* Leave the connection info below as it is: just edit the above. (Editing of code past this point recommended only for advanced users.) */ //create MySQL connection $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno()); //select database $Db = @mysql_select_db($DB_DBName, $Connect) or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno()); //execute query $result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno()); //if this parameter is included ($w=1), file returned will be in word format ('.doc') //if parameter is not included, file returned will be in excel format ('.xls') if (isset($w) && ($w==1)) { $file_type = "msword"; $file_ending = "doc"; }else { $file_type = "vnd.ms-excel"; $file_ending = "xls"; } //header info for browser: determines file type ('.doc' or '.xls') header("Content-Type: application/$file_type"); header("Content-Disposition: attachment; filename=database_dump.$file_ending"); header("Pragma: no-cache"); header("Expires: 0"); /* Start of Formatting for Word or Excel */ if (isset($w) && ($w==1)) //check for $w again { /* FORMATTING FOR WORD DOCUMENTS ('.doc') */ //create title with timestamp: if ($Use_Title == 1) { echo("$title\n\n"); } //define separator (defines columns in excel & tabs in word) $sep = "\n"; //new line character while($row = mysql_fetch_row($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; for($j=0; $j<mysql_num_fields($result);$j++) { //define field names $field_name = mysql_field_name($result,$j); //will show name of fields $schema_insert .= "$field_name:\t"; if(!isset($row[$j])) { $schema_insert .= "NULL".$sep; } elseif ($row[$j] != "") { $schema_insert .= "$row[$j]".$sep; } else { $schema_insert .= "".$sep; } } $schema_insert = str_replace($sep."$", "", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); //end of each mysql row //creates line to separate data from each MySQL table row print "\n----------------------------------------------------\n"; } }else{ /* FORMATTING FOR EXCEL DOCUMENTS ('.xls') */ //create title with timestamp: if ($Use_Title == 1) { echo("$title\n"); } //define separator (defines columns in excel & tabs in word) $sep = "\t"; //tabbed character //start of printing column names as names of MySQL fields for ($i = 0; $i < mysql_num_fields($result); $i++) { echo mysql_field_name($result,$i) . "\t"; } print("\n"); //end of printing column names //start while loop to get data while($row = mysql_fetch_row($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; for($j=0; $j<mysql_num_fields($result);$j++) { if(!isset($row[$j])) $schema_insert .= "NULL".$sep; elseif ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; else $schema_insert .= "".$sep; } $schema_insert = str_replace($sep."$", "", $schema_insert); //following fix suggested by Josue (thanks, Josue!) //this corrects output in excel when table fields contain \n or \r //these two characters are now replaced with a space $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); print "\n"; } } ?> [/code] Lite...
  24. Is this close to what you are looking to do.... http://www.nstoia.com/toh/technical/listdir/index.php (click on the example to see an... well example) Lite...
  25. Scenario: have an image upload form which works perfectly ([color=red]why not - it could happen[/color]). Fields are (1) the file to upload; (2) Caption for the image; and (3) a textarea for a brief description. The user is given an option on the form to 'preview'. When selected the script (a) uploads the file; and (b) redisplays the form with all the info filled in AND displays the image. The Problem: ok, ok so its not perfect!. I am able to re-display caption and the description in their respective fields; however; I am having a bit of a problem with the image 'path/name'. The Question: How, if it is possible, can one re-display the original 'path/name' in the appropriate field? ie. the file resides on user's computer at c:\just my pictures\my_dog_fluffy.jpg ([i][b]ok so its a sissy dog[/b][/i]) Thanks, Lite...
×
×
  • 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.