Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. use mysql administrator.... http://www.mysql.com/products/tools/administrator/ 2mb and 40,000 records is nothing........
  2. check the permissions of the folder you are moving the files to...if you are using *nix do "chmod 0755 foldername". If windows, turn on "modify" permissions for the web username.
  3. Aside from cluttering the global namespace, it places vars in a global context needlessly. So, if for example you have another function in your page that has a variable with local scope (to the function) that has the same name, it would be over ridden by the global. In writing your own scripts, you can probably avoid that, but if you decide to use another person's class or function for something, it can cause conflicts.
  4. by executing an SQL query... mysql_query("INSERT INTO table_name (current_time) VALUES (NOW())") or die(mysql_error());
  5. http://www.php.net/imagefontwidth http://www.php.net/imagefontheight http://www.php.net/imageloadfont
  6. Notices are just that...notices...they aren't an error, just php telling you that, in this case, a variable is being used before it's defined. Put this at the top of your script: ini_set("display_errors", 0); That should hide all errors, which is recommended on a website that is visible to the world. Alternately, you can "turn down" the error reporting level using this: error_reporting(E_ALL ^ E_NOTICE);
  7. I think, and I could be wrong, that the mysql_insert_id function gets the id of the last inserted row by a connection, not from the table overall. Since the server, both mysql and php, keep each connection seperate, even if a thousand other queries happen from other users visiting a page, it shouldn't affect the result of the function.
  8. I use jpgraph to generate images of charts and such... http://www.aditus.nu/jpgraph/
  9. It needs to be passed to the function or made a global... function addComment($bandid) { if (isset($_SESSION["authenticatedUser"])) { echo ' <form id="form1" name="form1" method="post" action="addcomment.php"> Comment: <br /> <input name="hiddenField" type="hidden" value="' . $bandid . '" /> <br /> <textarea name="commentBox" id="commentBox"></textarea> <br /> <br /> <input name="Submit" type="submit" class="button" value="Submit" /> </form>'; } else { echo '<h2>Please log in to post a comment.</h2>'; } } or if it's passed in the POST... function addComment() { if (isset($_SESSION["authenticatedUser"])) { echo ' <form id="form1" name="form1" method="post" action="addcomment.php"> Comment: <br /> <input name="hiddenField" type="hidden" value="' . $_POST['bandid'] . '" /> <br /> <textarea name="commentBox" id="commentBox"></textarea> <br /> <br /> <input name="Submit" type="submit" class="button" value="Submit" /> </form>'; } else { echo '<h2>Please log in to post a comment.</h2>'; } } or, as a last resort, and not recommended at all, but given for example purposes (it's not good OOP practice to do it this way): function addComment() { global $bandid; if (isset($_SESSION["authenticatedUser"])) { echo ' <form id="form1" name="form1" method="post" action="addcomment.php"> Comment: <br /> <input name="hiddenField" type="hidden" value="' . $bandid . '" /> <br /> <textarea name="commentBox" id="commentBox"></textarea> <br /> <br /> <input name="Submit" type="submit" class="button" value="Submit" /> </form>'; } else { echo '<h2>Please log in to post a comment.</h2>'; } }
  10. You need to create a multidimensional array...look at the result of the print_r to get a good idea of what's going on. <?php if ($_POST['actions']) { foreach ($_POST['actions'] as $key => $value) { print "player wants to $key the item $value<br />\n"; } } $query=mysql_query("select iname,itemid from items where ownerid='$sid' and equipped='no' and usf='no' and auction='no'")or die(mysql_error()); echo ' <script type="text/javascript" src="http://www.shawnolson.net/scripts/public_smo_scripts.js"></script> <form method="post" action="inventory.php?action=multiple"> <table class="tstyle5"> <tr> <th class="tstyle5" width="50">Item</th> <th class="tstyle5" width="50">Stock?</th> <th class="tstyle5" width="50">Auction?</th> <th class="tstyle5" width="50">Give Away?</th> <th class="tstyle5" width="50">Donate?</th> <th class="tstyle5" width="50">Discard</th> </tr>'; while ($row = mysql_fetch_array($query)) { echo ' <tr> <td><b>' . $row[iname] . '</b></td> <td><INPUT type="radio" value="actions[stock][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[auction][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[giveaway][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[donate][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[discard][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> </tr>'; } echo ' <tr> <td> <input type="radio" name="checkall" onclick="checkUncheckAll(this);"/> <input type="submit" name="delete" value="delete"> </td> </tr> </table> </form>'; echo '<pre>' . print_r($_POST, true) . '</pre>'; ?>
  11. In files. This question has a yes and no answer. Yes, you can insert them into the database, however, when a file upload occurs php automatically writes it to a temporary file, which is cleaned up automatically after the script concludes execution. So, in order to insert them into a database, you must use one of the file read functions on the file located at the location stored in the 'tmp_name' location in the $_FILES['form_field_array'] array.
  12. "exit" from the single quote using another, then concatenate the variable with your echo statement... function addComment() { if (isset($_SESSION["authenticatedUser"])) { echo ' <form id="form1" name="form1" method="post" action="addcomment.php"> Comment: <br /> <input name="hiddenField" type="hidden" value="' . $bandid . '" /> <br /> <textarea name="commentBox" id="commentBox"></textarea> <br /> <br /> <input name="Submit" type="submit" class="button" value="Submit" /> </form>'; } else { echo '<h2>Please log in to post a comment.</h2>'; } }
  13. Just like you make any other link...put in inside an anchor tag... <? for ( $i = 0; $i < 1; $i++ ) { echo '<td align="center"><a href="nextpage.php"><img src="' . $pics[$i] . '" width="375" height="257" border="0"></a></td>'; } ?>
  14. I don't think Malaysia is 80 hours ahead of GMT.... Anyway, I haven't tested it, but I think you can do something like.. $date = mktime(80, 0, 0, date("m"), date("d"), date("y"));
  15. use mysql_real_escape_string on the variable before putting it into the query... http://www.php.net/mysql_real_escape_string
  16. Once you query LDAP it returns basically a large multidimensional array that you can then parse through and use the data however you like...put in a new array or what-not... //connect to your ldap server $dn = "ou=sales, DC=USA"; //use your base DN here $filter = "(|(sAMAccountname=*))"; $search_result = ldap_search($ldap_connection, $db, $filter) or die(ldap_error($ldap_connection)); $result = ldap_get_entries($ldap_connection, $search_result); for ($i = 0; $i < $info['count']; $i++) { echo '<pre>' . print_r($info[$i], true) . '</pre><br />'; //if you wanted to know, for example, what groups they are a member of... echo '<pre>' . print_r($info[$i]['memberof'], true) . '</pre>'; }
  17. sessions use cookies...if output has been sent to the browser before it can send the cookie header, it will fail. EDIT: This means that if you have a newline at the top of your php script, before the opening tag, it will output a newline...which will cause your header to fail... ///top of file, blank "newline" can't be here <?php .... ?>
  18. Why does everyone think MD5 can be reversed / decrypted? Neither MD5 or SHA1 has been "broken". Some Chinese mathematicians have discovered that it is possible to generate a collision for the two HASHING algorithms. They don't encrypt, they hash...encryption is designed to be reversed to get the original string back. A hash attempts to generate a unique identifier for the hashed value. If you want to know more about the collisions, read the wikipedia articles on MD5 and SHA1. Despite the fact that collisions can be generated, it isn't the easiest thing in the world to do. Even if it was, the "hacker" would need to know what the MD5, or SHA1, hash is. That is normally not something you should be just giving out. So, in order for the attacker to get the hash, they would have to already have access to your database...at which point they can just create their own user name and password. Before anyone says anything about the websites that claim to reverse md5, they don't reverse anything...they compare the provided hash to the values stored in a database and hope for a match...the largest, I think, has 40 million records...the possible number of hashes for MD5 is 2^128...which is WAAAAAYYYYYYY more than 40 million. In terms of hash strength, the mysql PASSWORD is 41 bytes long and md5 is 128 bytes long. I don't remember how long SHA1 is (I think 160, but not sure). I encourage you to read more about hashing and make a decision for your self. Neither MD5 or SHA1 has been reversed, however there is a (VERY) remote possibility of a collision being found for both. http://en.wikipedia.org/wiki/Sha1 http://en.wikipedia.org/wiki/Md5 http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html
  19. That's not an error...it's a textual representation of an array ( http://www.php.net/print_r )...my guess is the $_FILES array.
  20. Where is your query? use a "WHERE" statement on the end of your query... SELECT * FROM table_name WHERE year = '2007'
  21. Use the modulus operator to get what you want... $money_paid = 100; $price_of_goods = 54.37; $change = $money_paid - $price_of_goods; $fiftys = floor( $change % 50 ); $change = $change - ($fiftys * 50); $twentys = floor( $change % 20 ); $change = $change - ($twentys * 20); //etc for the other denominations of money..... //then echo out each denomination...
  22. oops, forgot the concatenation operator... ${$check . $num} = 'value'; EDIT: An example: $check = 'value'; for ($i = 1; $i < 10; $i++) { ${$check . $i} = $i + 10; } echo $value1 . '<br />'; echo $value2 . '<br />'; echo $value3 . '<br />'; echo $value4 . '<br />'; echo $value5 . '<br />'; echo $value6 . '<br />'; echo $value7 . '<br />'; echo $value9 . '<br />'; echo $value9;
  23. I think what you want is... ${$check$num} = 'value';
  24. if(!ereg("[a-fA-F0-9]{6}", $string)) Using that you could also eliminate the check for string length above the ereg 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.