Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. I don't think php will parse the increment operator when it's inside of quotes... echo "<td>" . $i++ . " " . $clutch[name] . "</td><td>" . $clutch[id] . "</td>";
  2. Would put a random number before each entry...I think he wants a sequential number... $i = 0; while($jnfw){ echo ++$i . $jnfw[blah]; }
  3. Read this page.... http://us.php.net/manual/en/features.file-upload.php Pay special attention to the "Note:" block just below example 38.1
  4. Ok, I see you are using the XML dom functions that were adapted for html...I wouldn't recommend using these without a compelling reason...the manual lists them as being in CVS only, which means they are not well documented and may not work as expected. Anyway, off hand I don't know how to get the line number. You may try doing a print_r or var_dump on the object to see the full listing of data that it contains. You never know...it may have the line number stored somewhere.
  5. This should work...although I haven't tested it. <?php $Query = "SELECT * FROM observations order by location"; $Result = mysql_db_query($DBName, $Query, $Link); //put the data in an array we can access out of order (not linearly) while ($Row = mysql_fetch_array ($Result)) { $data[] = $Row; } //start the table echo ' <table> <tr> <td>First column</td> <td>Second column</td> </tr>'; //loop through...we only want the first half directly...we'll get the second //half through addition. for ($i = 0; $i < floor(count($data) / 2)); $i++) { $col_2 = $i + floor(count($data) / 2); echo ' <tr> <td>' . $data[$i]['location'] . " " . $data[$i]['humidity'] . " " . $data[$i]['oktas'] . '</td> <td>' . $data[$col_2]['location'] . " " . $data[$col_2]['humidity'] . " " . $data[$col_2]['oktas'] . '</td> </tr>'; } //check to see if there is an odd number of rows...if there is, add on the odd one if (count($data) % 2 == 1) { echo ' <tr> <td> </td> <td>' . $data[count($data) - 1]['location'] . " " . $data[count($data) - 1]['humidity'] . " " . $data[count($data) - 1]['oktas'] . '</td> </tr>'; } //close the table echo ' </table>'; ?>
  6. Yep, anything is possible...in fact I just won the lottery, was struck by lightning, and hit by a meteorite...all at the very same instant...and it's half price snow cone day in hell...and the devil is giving free sleigh rides...and the ice cube safely traversed hell's fire fields. It's all mathematically possible. Good luck with that whole "hacking" md5 thing.......
  7. You don't parse a DOM with php...that's javascript, and xml depending on your use. Anyway, the way it's done is by using the file command...it reads a file into an array separating elements by the newlines...since arrays have keys that are an integer increment by default, it means that the line numbers become the element key + 1. Alternately read the file into a string, then split it on the newline characters...ultimately giving you the same result as using the file command. http://www.php.net/file
  8. You can not call a php function from an html form. The action attribute should be equal to the name of the page that the form is submitted to. php is server side. Html is client side. If you want to validate a form client side (using the onsubmit attribute of the form) use javascript.
  9. Well, lets do some simple math here...md5 is a 128 bit hash. This means that there is 2^128 possible hashes...which I think comes to something like 3.4028 * 10^38 possible hashes. So, unless there are something along the lines of many billion billion billion users to a website, it's not going to happen. To put it another way, you, your parents, your grandparents, your dog, his parents, and his grandparents all have a better chance of winning every lottery in the world, at the exact same time, than finding a collision "by chance".
  10. The only known "hack" for md5 is to find a collision for a given hash. This means that rather than trying a reverse lookup for a hash, to find another phrase that generates the same hash. Which is grand and all...apparently some people have found a way to do it in less than 60 seconds (http://cryptography.hyperlink.cz/MD5_collisions.html), however, none of that matters if they don't know what the hash is to begin with. So, in order for someone to gain access to the password protected content, they would have to gain access to the database, retrieve that user's password hash, find a collision, then use it to gain access...which begs the question, why go to the trouble of finding the collision if they have access to the database anyway? More information can be found here: http://en.wikipedia.org/wiki/MD5 http://www.unixwiz.net/techtips/iguide-crypto-hashes.html http://www.cryptography.com/cnews/hash.html
  11. if there is no value for xyz, it won't be added to the sum...conversely, if it has a value more than 1, that value will be added to the sum. To answer your question...the same place you always would....after the FROM statement, before the GROUP BY statement.
  12. Try the isset, empty, and is_null functions... http://www.php.net/isset http://www.php.net/empty http://www.php.net/is_null
  13. $text = array("Yes", "Maybe", "No"); //try $id = array_rand($text); echo $text[$id]; //or shuffle($text); echo $text[0];
  14. In an array you can address the elements individually..i.e. $array_name['element_name']. In the mysql object you can only address them in a linear fashion...i.e. through a while loop. while ($row = mysql_fetch_assoc($result)) { $data[$row['id'] = $row; } You can then address the items by their id... echo $data[1]['username']; Or if you use the username as the key... while ($row = mysql_fetch_assoc($result)) { $data[$row['username'] = $row; } echo $data['gazalec']['post_count'];
  15. or... echo $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING'];
  16. $query = "SELECT userid, SUM(xyz) AS hits FROM table_name GROUP BY userid ORDER BY hits DESC"; $result = mysql_query($query) or die(mysql_error()); echo ' <table> <tr> <td>Userid</td> <td>Count</td> </tr>'; while ($row = mysql_fetch_assoc($result)) { echo ' <tr> <td>' . $row['userid'] . '</td> <td>' . $row['hits'] . '</td> </tr>'; }
  17. make sure that you are displaying errors... At the top of your page put: ini_set("display_errors", 1); error_reporting(E_ALL);
  18. Echo out your query and make sure that it is correct... $result = mysql_query($query) or die($query . '<br />' . mysql_error());
  19. yes. Use the GD functions to generate the image. Then use the url of the page as the "src" attribute of your img tag.
  20. use an array... http://www.php.net/array
  21. The way I would do it would be to break them into separate sub arrays... while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $first_letter = strtoupper(substr($row['game_name'], 0, 1)); $letters[$first_letter] = $row['game_name']; } ksort($letters); echo '<pre>' . print_r($letters, true) . '</pre>';
  22. Write your sql query to retrieve the cell number from the database, then loop through the directory using the dir commands... $query = "SELECT id FROM tablename WHERE cellnumber = 1234567890"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { //use dir functions to find the file... //reference this page: http://us2.php.net/manual/en/function.opendir.php#id3253365 //if file is found, echo html to display here. }
  23. No one here will write it for you. You can find literally hundreds of scripts already written to do this by using google... phpclasses alone has over 200 results returned for the keyword "thumbnails". http://www.google.com/custom?domains=www.phpclasses.org&q=thumbnails&sa=Search&sitesearch=www.phpclasses.org&client=pub-2951707118576741&forid=1&channel=5742870948&ie=ISO-8859-1&oe=ISO-8859-1&cof=GALT%3A%23663399%3BGL%3A1%3BDIV%3A%23222222%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AA3C5CC%3BLBGC%3AA3C5CC%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BLH%3A50%3BLW%3A256%3BL%3Ahttp%3A%2F%2Ffiles.phpclasses.org%2Fgraphics%2Fgooglesearch.jpg%3BS%3Ahttp%3A%2F%2Fwww.phpclasses.org%2Fsearch.html%3BFORID%3A1%3B&hl=en
  24. Once you create your table, you need to insert the values in the correct order. Aside from that, just use the file function to read the file, then use explode to get the separate fields... $file = file("./path/to/file.txt"); foreach ($file as $line) { $line = explode(":", trim($line)); //do any field preparation here... //form your query... $query = "INSERT INTO table_name (ICAO, IATA, Airport_Code, City, Country, etc, etc, etc) VALUES " . "('" . $line[0] . "', '" . $line[1] . "', '" . $line[2] . "', etc, etc, etc)"; mysql_query($query) or die(mysql_error()); } The only advantage you have of doing it that way is you are able to manipulate the fields before they are entered into the database. An easier way would be to use MySQL's "LOAD DATA INFILE" function... http://dev.mysql.com/doc/refman/5.0/en/load-data.html If you don't want to use the command line utility, use the graphical MySQL Administrator... http://dev.mysql.com/doc/administrator/en/mysql-administrator-main-window-introduction.html
×
×
  • 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.