Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. By the way, what is the XML you're reading from?
  2. If the XPath method (like SimpleXMLElement::xpath or DOMXPath::query) doesn't issue warnings in case of a syntax error, you can just run it and see if it works. Doesn't even have to match anything. Otherwise... probably need regular expressions, but one that would validate an XPath query would be insane. If you can restrict the query to a limited set of features then that'd help.
  3. dot-all . doesn't normally match newlines. Use the /s flag to make it do so. Also use an ungreedy .*? inside your expression or else it might not match the way you want it to. preg_match_all('#(.*?)#s', $file_string, $titles);
  4. Try with the loop for the photos inside the $preownedinfo loop, and then with it looping over $preownedinfo->AdditionalPhoto: <?php $preowned = simplexml_load_file('file.xml'); foreach ($preowned as $preownedinfo) { $price = '$' . money_format($preownedinfo->Price, 2, '.', ','); $photosHTML = ''; foreach ($preownedinfo->AdditionalPhoto as $addphoto) { $photosHTML .= "<li>$addphoto</li>"; } echo...
  5. A browser plugin? Please. Is there something wrong with adjusting your HTML and CSS until it fits the labels correctly?
  6. foreach ($AdditionalPhoto as $addphoto); echo "<li>$addphoto</li>"; endforeach;Wrong syntax. Either use normal {}s foreach ($AdditionalPhoto as $addphoto) { echo "<li>$addphoto</li>"; }or the alternative syntax which uses a colon (not a semicolon) foreach ($AdditionalPhoto as $addphoto): echo "<li>$addphoto</li>"; endforeach;However given that you use the alternative syntax correctly earlier I'm going to guess the semicolon is a typo.
  7. Assuming you want to loop through the players and find matching injuries, you don't have to create one big array - you just need them in the right structure. Create a new injuries array that uses the player ID as the array key. array( 10009 => array(status, id, details), 10012 => array(status, id, details), ... )Note that if you output this new array you'll see that the array keys will be numbers and not strings - if #0251 had an injury it would be under the 251 array key. However PHP will handle the conversion for you so you don't need to worry about it. If it's possible to have multiple injuries on a player then you'll actually need a 2-D array array( 10009 => array( array(status, id, details), array(status, id, details), ... ), ... )(since you can't use an array key twice), which implies more complicated logic than simply $id=>$data such as if (isset(new injuries array[player])) { new injuries array[player][] = data } else { new injuries array[player] = array(data) }
  8. Saying that doesn't tell us anything. You have to actually explain how it's not working. What is it doing? What did you expect it to do? What have you tried to do to fix it?
  9. Just have to pay attention to little things. The error told you where the error was so your first step should be to look at the line very carefully and see if there aren't any little mistakes like that.
  10. mysqli_connect mysqli_connect_errno mysqli_connect_error mysql_query mysqli_query mysqli_fetch_array mysqli_close
  11. Temporarily use $requests = mysql_query("SELECT * FROM users, friendrequests WHERE touser='$username' AND fromuser=username ORDER BY requestid ASC") or die(mysql_error());and find out why your query failed. (Which is what happened.) Also, 1. The mysql extension and mysql_* functions are dead. Switch to mysqli or PDO. 2. Use a real JOIN instead of the comma. SELECT fields FROM users JOIN friendrequests ON whatever conditions to join them together WHERE the rest of your conditions... ORDER BY requestid ASC Good. It's telling you about all the things going wrong.
  12. Two seconds: If you're still unsure what I'm getting at, try writing out a list of the functions you're using in this file. Carefully.
  13. You're not adding yet another table. You're creating a new table for all the users and getting rid of the four you have now.
  14. Don't use four tables if one will do. Then add a column to it indicating what type of user is in each row.
  15. Use the query SHOW TABLES FROM databaseand grab the values from the first (and only) column.
  16. Forget "design patterns" for a second, okay? That's just a fancy term for a group of more fancy terms for how you architect your code. What values? Do they change? Where do their values come from? Where do you need to use them? How are they used?
  17. It'll check any hostname you provide via the form, not just the "internal" database.
  18. AppDownload needs to be only a URL. No quotes, no target=_blank. Then echo "Download";
  19. Firebug isn't technically for PHP but for other things that are important in web development so yes, if you use Firefox then it's a good idea.
  20. No, it's proper JSON. json_decode(), loop over "report", and each item's [0] is the ID. Try writing code for that.
  21. Either you have the wrong class name, your autoloader isn't working, or your autoloader isn't finding the right file. Given how little you've posted, I don't know which of those it is. Have you tried... say... debugging? Your autoloader would be the first place to start.
  22. You can't simply copy and paste stuff from place, put it somewhere else, and expect it to work. On that note you can't simply modify PHP code without knowing any PHP and expect that to work either. Forget the code you have now. What is the code for the rest of the file and what are you trying to change about it?
  23. That's only a part of what you would need, and even then I think what it's getting at isn't a good idea. Move the files someplace not web accessible, then make a PHP script which (1) validates that the user is allowed to download the file (which is given in the URL, like the query string) and (2) dumps out the contents of that file if so. The "dumps out the contents" part looks like // assuming you have $file = the path to the file to download header("Content-Type: application/pdf"); // for PDF files, something else for other files header("Content-Length: " . filesize($file)); header("Content-Disposition: attachment; filename=" . basename($file)); readfile($file); exit;As for the "something else", it varies based on the type of file: PDFs = application/pdf MP3s = audio/mp3 JPGs = image/jpeg For images in general you can use getimagesize() and the "mime" it returns. // grab the file $extension if (in_array($extension, array("jpg", "jpeg", "gif", "png"))) { $info = getimagesize($file); $type = $info["mime"]; } else if ($extension == "pdf") { $type = "application/pdf"; } // etcThat all will take care of the sharing problem because only people logged in and able to get the file can get it. You don't need one-time URLs. If you really do want one-time URLs (IMO not worth the effort) then you'd also 1. Create a database table that tracks random IDs, the files they're associated with, and whether it's been used or not 2. Insert records when you present a download link 3. Your download script takes one of those random IDs instead of the file, looks up the relevant information, decides whether to allow the download or not, and continues appropriately Optionally include an expiration time on those random IDs.
  24. Why the heck do you close the connection right after opening it?
×
×
  • 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.