Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. Ok, I'll explain this suggestion and then I'll post my revision. First off, you are creating the displayBody function in an else statement. While I can understand the reason you did this, it serves no purpose whatsoever.. other than possibly saving some memory. Remember, the function WILL NOT run unless you tell it to, so simply declaring it in the beginning of the script won't hurt. Secondly, if the text inside the function is the ultimate text that you want, then why are you mingling it into your validations? The purpose of the validation process is to throw errors.. not success messages. Ideally, you would want to have the function call after all the validations have passed. Lastly, you lack to use a very important function in PHP known as isset(). This function serves as a way to determine if a variable exists or not.. On last note, if you only have one thing for an IF statement to do when it's true, you DON'T NEED curly braces for it. With all that said, I'll show you some code, but I wouldn't recommend overwriting everything you have just to test it..as I haven't even tested it. Try making a duplicate file and see how that works out... then tell me what's wrong. It is possible that I didn't even follow the procedure you intended. include_once("includes/config.php"); /// Put your function up here function displayBody($id, $extract) { mysql_query("UPDATE skins SET views = views + 1 WHERE id = '$id'"); $c = $extract['title']. ", by ". $extract['username'] .". Description: ". $extract['description'] ." - Download "; return $c; } if(!isset($_POST['password']) || empty($_POST['password'])) $content = " Password Password: "; if(!isset($_GET['id']) && isset($_POST['id'])) $id = mysql_real_escape_string($_POST['id']); elseif(!isset($_POST['id']) && isset($_GET['id'])) $id = mysql_real_escape_string($_GET['id']); else $id = null; if(empty($id)) $content = "Sorry, you have not selected a skin to view."; else { $data = mysql_query("SELECT title,username,id,password,description FROM skins WHERE id = '$id' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($data) == 0) { $content = "Sorry, no skin exists with this ID."; if(isset($_GET['download'])) $content = "No skin exists with this ID, so you may not download."; } else { $extract = mysql_fetch_assoc($data); if($_POST['password'] != $extract['password']) $content = "You have entered in an incorrect password. Try Again or Home."; else { if(isset($_GET['download'])) { mysql_query("UPDATE skins SET downloads = downloads + 1 WHERE id = '". $id . "'"); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=skins/".$extract['id'].".png"); header( "Content-Description: File Transfer"); @readfile($file); $content = displayBody($id, $extract); } } } } ?> MCSkins Furthermore, I have no idea why I did all this, I must be extremely bored. Oh yeah, another thing I noticed in your code is that you repetitively make the same MySQL queries over and over, when you could easily do it once and be done with it.
  2. Actually, since the letters only go to F, you don't need to look all the way to z... preg_match('#^[a-f0-9]{32}$#i', $_GET['something']);
  3. Have you tried doing it without globals yet? Even if you used globals it would act the same way if you were to use my suggestion. You could also set $content by reference inside your function.. like function displayBody($id, $extract, &$content) { $content = "The text you want to display"; } Regardless of what you do, as soon as you assign something new to $content it will be overwritten. Setting it global isn't just a no-no, it's a waste of memory, redundant, usually not supported on every server.. and to top it off, PHP6 will not even support globals. Most of this probably won't affect your script enough to notice and you probably won't even care about the "bad practice" of it so long as your script works, but that's the only reason I have behind the global no-no theory. I'm sure you can google plenty of better reasons why not to use them. Nevertheless, your question isn't about globals, it's about setting $content to something dynamic... and echoing it at the bottom. If you haven't already, try my suggestion... If you have and it doesn't work... post the revised code and we can work from there.
  4. the $content that is inside displayBody() and the $content that you echo at the bottom of the page are two separate variables. In other words.. they are in different scopes. You could make $content global but I don't recommend it, just for the fact that globals are a no-no. What you need to do is set $content to equal the return of displayBody(); for example $content = displayBody($id, $extract);
  5. Check out levenshtein distance You could also look at soundex and metaphone.
  6. well I'll be damned. my bad. Well the only reason I can think of is the doctype is wrong.. or non existent. Does your page have any of the following doctypes? HTML5: HTML4 Strict: HTML4 Transitional or Loose:
  7. because your displayBody function doesn't echo anything... it only returns.
  8. what does your code look like now
  9. "Missing argument 2" is shorthand for "You are missing the second argument/parameter" displayBody($id); See, there is only one argument
  10. and input tag does not have a src attribute I believe you're looking for the img tag and if you want it to be the submit button, use some JavaScript in there
  11. That was your golden answer right there. change all the checkbox values to "on"... don't remove them Also, the value you put in the checkbox has no purpose if you're just going to change it. You're best bet is to check if the variable even exists if(isset($_POST['Keukens'])) $Keukens = "Jaa"; else $Keukens = "Nee";
  12. Here's a valuable thread for you http://www.phpfreaks.com/forums/index.php?topic=208965.0
  13. That should be the new motto for this place.
  14. You've got the right idea... initially.. although I don't see any actual links in your code, but I'm going to assume you just left that part out. Since you are selecting multiple rows, you have to account for every one of them or else you'll just end up with the first one that meets the query criteria. If you notice in your posted code it LITERALLY tells you this.. though it won't give you an error unless there are no rows whatsoever. In order to use all the returned rows you have to use a loop.. and the MOST COMMON way is to use a while loop $res = mysql_query($query, $ms); while($result = mysql_fetch_assoc($res)) { echo "id: ".$result['id']." "; echo "username: ".$result['username']." "; echo "type: ".$result['type']." "; echo "title: ".$result['title']." "; echo "description: ".$result['description']." "; echo "county: ".$result['county']." "; echo "town: ".$result['town']." "; echo "phone: ".$result['phone']." "; echo "rooms: ".$result['rooms']." "; echo "bath: ".$result['bath']." "; echo "square: ".$result['square']." "; echo "rent: ".$result['rent']." "; echo "time: ".$result['time']." "; }
  15. Like jordanmoore pointed out, the ONLY way to "crack" MD5 would be through a collision. And more realistically it is impossible to decrypt an MD5 hash. I don't care how many website there are out there they say they can do it, those sites are only looking to get traffic and what better way to do it than to offer something that isn't real. Imagine that we were using MD5 for voice encryption, which could be done. If I encrypt my voice saying "Hello Zanus".. it is theoretically possibly that someone could attempt to mimic my voice and possibly be authenticated. BUT, if I also add a salt.... an extra little voice, automatically added to all my voice passwords, then it is at least 1000 times or more ... more difficult to mimic.
  16. Unless of course you stored all that data in a SESSION, which probably isn't the wisest choice, but it would do the trick. That's what SMF (the forum software used here) does... although they have databases... they store the most relevant information in a SESSION variable.
  17. If it's $reg you want to put in the Content Length, then what is $req?
  18. are you sure $req even exists? Did you declare it before you attempted to concatenate it?
  19. jQuery is nothing more than what has already been said... a framework. By definition.. a framework is If that's too vague then I'll spell it out. In the beginning, there was Javascript. There are literally thousands (probably billions) of different ways to use the language. The only problem with each new idea as technology progresses is that the javascript scripts get broader and broader... and broader. So eventually someone is destined to come along and say, I'm going to shorten these 500 lines of code to 50 and make it do the same thing, if not better. Essentially, jQuery is just a language written from Javascript code. If you look inside the jquery core file you'll see Javascript and lots of it, but the code is condensed and obfuscated so much that one would probably think it's alien. The moral of the story is, jQuery isn't required to do the things it CAN do, but it sure as hell makes it easier to implement. Just as an example, if you wanted to create a simple AJAX script using plain ole Javascript, you must determine: - the browser being used and it's version - and which XML object to create according to the browser. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } .. and that code only determines which browser is used and starts an "AJAX" object accordingly.. there are no variables sent (AJAX'd) anywhere In jQuery, it's as simple as $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); In this code, the Object type has already been determined and the variables are even being sent. Does that clear things up? Also, this should be moved to the Javascript Forum, it's apparent from the OPs last reply that this is a question.
  20. Once you get this formula down, you could make about any kind of geographical type program. Just combine it with creativity.
  21. a foreign key is just that.. a foreign key. Foreign as in, the key doesn't exist in the current table. a fk to users would just be a one of the primary keys from the users table.
  22. did you try strtotime("-$j day")
  23. $_POST['addvalue']
  24. There is no reason to use extract.. The best route in storing the data would be something like this while($row = mysql_fetch_array()) $data[] = $row; That way you have one variable full of arrays. Now you can do something like this foreach($data as $index=>$value) { $data[$index]['var1'] += $data[$index]['var2']; } That most likely WILL NOT work, but I hope you get the idea.
  25. So the function runs recursively (again and again) until $count != 1 ... or in the case of my example... until count is less than 1
×
×
  • 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.