Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. It's not pretty, but it works: [code]$fractions= array(); for ($i = 1; $i < 1000; $i++) { $v = 1 / $i; $fractions['1/' . $i] = $v; } $a = array(6.5, 7.25, 1.125); foreach ($a as $num) { $num = explode(".",$num); foreach ($fractions as $key => $value) { if ($value == "." . $num[1]) { echo implode(".",$num) . " = " . $num[0] . " " . $key . "<br>"; } } }[/code]
  2. I was hoping Barand would help here...he is an SQL genius
  3. [quote]how to plan the code files and folders to its clean and effinecent[/quote] This is something that is very subjective...what is "clean and efficient" to me, may not be to you.  Generally, I tell people who work for me to do what is logical to them, and just make sure to document everything clearly, which leads me to your second question... [quote]is there such a thing as commenting too much?[/quote] If at any point in the future there is the slightest possibility that someone else that may be less proficient will have to maintain your code, then -- generally -- no, you can not comment to much.  You can always go overboard with anything, just keep it reasonable.  When I code, I usually only comment blocks of code so  in the future I can come back and look through the code and remember what I'm doing.  I don't need to comment each and every line and function that I'm doing...for me or for anyone else that I work with, but that may not always be true.
  4. You all are still missing the single quote before $first_name.
  5. You are missing one of your single quotes...the one first one on $first_name. [code]$sql = "INSERT INTO $table_users VALUES('$userid', --> ' <-- $first_name', '$last_name', '$email_address', '$username', '$mdpwd', '$today')";[/code]
  6. You should remove your personal email and phone number from your post above!! Also, you can quickly do [code]$visitor = $_POST['visitor']; $visitoraddress = $_POST['visitoraddress']; $paymentmethod = $_POST['paymentmethod']; $posterstyle = $_POST['posterstyle']; $posterline = $_POST['posterline']; $playername = $_POST['playername']; $colors = $_POST['colors']; $maintext = $_POST['maintext']; $smalltext = $_POST['smalltext']; $playernumber = $_POST['playernumber'];    $mainphoto = $_POST['mainphoto'];[/code] by using extract: [code]extract($_POST);[/code] Then, as AndyB suggested, make sure to remove anything malicious that the user may have input.
  7. Your first post doesn't make a lot of sense, but I did notice a few things... Why are you name it on the server's file system the temp name? [code]move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['tmp_name'])[/code] Use $_FILES['file']['name'] to name it the actual name of the file. You aren't being consistent in which member of the $_FILES array you are referring to: [code]if($_FILES['subfile']['size'] > $max_size)[/code] Where did subfile come from?  You use "file" in the others.
  8. What do you mean "trying to plan a website"?
  9. Zend has a good intro to creating and manipulating arrays, as well as some of the array related functions, and some loops. http://devzone.zend.com/node/view/id/635
  10. Why not use an if statement inside of your while loop? [code=php:0]while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {   if (($row['caption'] != $fileCaption) && ($row['name'] != $fileName)) {     ... whatever ...   } }[/code]
  11. These two tutorials will help you with what you want: Full text MySQL searches: http://www.phpfreaks.com/tutorials/129/0.php Paginating the results of your search: http://www.phpfreaks.com/tutorials/73/0.php
  12. it means exactly what it says... When you use include, it opens the file and reads the contents...the php intrepreter reads them just the same as if you had typed them in the including script...as opposed to the file functions which allow you to manipulate the data retrieved. What the error is saying is that php can not open the file...which isn't a file at all in your usage...it's a url.  So, if that url doesn't exist, then it can't open it.
  13. According to the manual, you can: http://mysql.com/doc/refman/5.0/en/mathematical-functions.html#id3220613 Which means that all he would have to do is get a random number, use it so seed mysql's RAND function, then store that number in a session to be used in all subsequent queries. Good suggestion.
  14. There is no good way of doing that.  The purpose of using RAND() is to get a different sort order each time. The only thing I can think of off hand would be to do your query, then store the result somewhere...in a session, or in a file, so that when the user goes to the next page you are able to retrieve the same result set and get the next 10 records for them to view.
  15. There is an open source class, phpgacl, that does what you want very well.  http://phpgacl.sourceforge.net/ GALs, or Generic Access Lists, are a very confusing topic to describe, however, the manual for phpgacl does an outstanding job.  Even if you don't use the class, I highly recommend reading about GALs in their manual for a better understanding. They even use the Star Wars characters in the examples, which makes it amusing to read if nothing else. A system very similar to phpgacl is used by Joomla and Drupal for their user control.
  16. Speed wise they are exactly the same.  Their precedence is different.  && is slightly higher than "and".  See here: http://us3.php.net/manual/en/language.operators.php#language.operators.precedence
  17. Your parenthesis are wrong" [code]while (($row['caption'] != $fileCaption) and ($row['type'] != $fileType) and ($row['size'] != $fileSize) and ($row['caption'] != $fileCaption))[/code] Using && or "and" makes little difference execpt in a very few, very specific situations.
  18. it's an easy way of using one block of code to accomplish something.  Using your example of an array with days of the week.  If you coded: [code]$monday = "monday"; $tuesday = "tuesday"; etc; [/code] and you wanted to change each of those to upper case, you would have to do something like this: [code]$monday = strtoupper($monday); $tuesday = strtoupper($tuesday); etc for each variable [/code] if you had an array of days... [code]$days = array('monday', 'tuesday', etc...);[/code] you would only need to use a loop: [code]foreach ($days as $k => $day) {   $days[$k] = strtoupper($day); }[/code] Three lines of code, as opposed to 7.  And that's only applying one operation...imagine if you had to do several
  19. Use SQL to do this for you: [code]SELECT gid.name, testbracket.points FROM testbracket LEFT JOIN gid ON testbracket.gid = gid.gid[/code] Then you can use SUM and GROUP BY to lump them together by name with the total points, or you can use an array to store the totals for each name: [code]$result = mysql_query("SELECT gid.name, testbracket.points FROM testbracket LEFT JOIN gid ON testbracket.gid = gid.gid"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {   $name = $row['name'];   if (!$data[$name]) {     $data[$name] = $row['points'];   } else {     $data[$name] += $points;   } }[/code] Then you can use the array sort or key sort functions to sort by name or points.
  20. Look at your echo line.  Specifically where you are echoing out the $score6 in the html. [code]echo " <tr> <td height=\"30\">● <a href=\"review.php?artid=$artid\" target=\"_parent\"><b>$title</b></a></td> $score6<td></td> <td>$aid</td> <td>$section</td> <td>$releasedate</td> <td>$publishdate</td> <td>$counter</td> </tr>";[/code] See anything wrong there? [code]$score6<td></td>[/code] should be [code]<td>$score6</td>[/code]
  21. [code]<select name="genre">   <option value="<? echo $_POST['genre']; ?>"><? echo $_POST['genre']; ?></option>                <?   while ($row = mysql_fetch_assoc($result_genre)) { echo '<option value="' . $row['odc_gen_id'] . '">' . $row['odc_gen_genname'] . '</option>'; }   ?> </select>[/code]
  22. You can use a js regular expression for this: [code]function checkpw(pass) { var m = /^[0-9a-zA-z]$/; if (!pass.match(m)) { alert("Please use only numbers and letters for your password."); return false; } else { return true; } }[/code] call is by using either a onsubmit on the form, or on blur on the form field: [code]<input type="password" name="password" size="10" onblur="checkpass(this);">[/code]
  23. [quote]I wanna know how I can make it case sensitive![/quote] You can't...at least not without core php hacking, and that's a lot of trouble when you can simply rename your functions to something like: [code]function ignace_isset($var1) {   ... }[/code]
  24. all function names are case insensitive.  Why are you wanting to redefine already existing functions? For your security question, refer to this thread: http://www.phpfreaks.com/forums/index.php/topic,103005.0.html Which is only about 10 threads down.  Please at least make the smallest effort to do a search before asking the same question as someone else has a million times before.
  25. Use double quotes: [code]echo "<title>$title</title>"; echo "<description>$title2</description>";[/code]
×
×
  • 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.