Jump to content

Orio

Staff Alumni
  • Posts

    2,491
  • Joined

  • Last visited

    Never

Everything posted by Orio

  1. They can.. But only on page 3 I could find an example, and that too was made by thrope... http://www.phpfreaks.com/forums/index.php/topic,217661.0.html Orio.
  2. Use file_exists(), not is_file(). Orio.
  3. Because all the rest of the input tags are set to name="text" instead of address/telephone etc' Orio.
  4. As I already mentioned: Example: <?php $filename = "folder/scripts/index.php"; echo basename($filename, ".php"); //Output- "index" ?> See more examples at the link provided... Orio.
  5. If users vote between 1 to 10, so SUM/NUM_VOTES would give the average (a number between 1 to 10). If you multiply it by 10 the rating would be between 10 to 100. But I think it's best if you use the same scale on both- people can vote between 1 to 10 and will see a rating between 1 to 10. Orio.
  6. I can't really glue these pieces of code together. Where does the last code part go? It'd be easier if you'd show the whole code. Orio.
  7. The simplest solution I can think of is adding two columns, one for the total count of votes (10+9+4+10+...) and one for the number of votes (1+1+1+1+....). Then you display the average. Orio.
  8. It's not a good idea to pass the whole reply. You have that reply stored in your database, just pass the ID and use that to fetch the reply from the db. Orio.
  9. I've never had to use the ZIP library, but I guess the problem is there somehow, if you are getting an empty folder. Try going over the piece of code that creates the archive with the manual as a reference to see if you're doing it right. Orio.
  10. I've added the 'm' modifier, so each line is treated separately (so ^ matches a start of a newline and $ an end of one). [^\s]+ matches everything until a space is met, so this way it skips the numbers and the dot. Then comes a literal space to match the space that comes after the dot. Then it captures everything until the end of the line (and because it's brackets it "saves" it as $1). The whole pattern is replaced by $1 - so you get only the song names. Orio.
  11. You have some error in your sql part. Change the $count_result line to: $count_result = mysql_query($sqlcount) or die(mysql_error()."<br><br>The query:<br>{$sqlcount}"); Orio.
  12. Try that: <?php $data = <<<DATA 8. 3 Doors Down - Kryptonite 207. Aerosmith - I Don't Want To Miss A Thing 1096. Coldplay - The Scientist 1097. Coldplay - Trouble 1832. FatBoy Slim - Praise You 1833. FatBoy Slim - Right Here, Right Now 2068. Green Day - Time your life DATA; $result = preg_replace("#^[^\s]+ (.*?)$#m", "$1", $data); echo $result; ?> Orio.
  13. Can you show an example of raw data you get (in code tags!) and the output you're expecting? Orio.
  14. Instead of giving a link (which I personally don't want to click), show the code and the errors you are getting. Orio.
  15. In the query I've counted how many posts were made to that topic. "COUNT(*) as C" saves that number as if it was stored in a column named "C". So then later I can access that number in $data['C']. The line you are talking about is using the ternary operator. (scroll down a bit for explanation about it). Basically, it says: <?php if(is_numeric($pagenum) && $pagenum >= 1) //Make sure that $pagenum is a number bigger-than/equal-to 1 $pagenum = (int)$pagenum; //Cast to int to round it (in case a float was given) else $pagenum = 1; //Default value- in case a invalid number was entered ?> Orio.
  16. Well if the site owner gives you permission to use his data, you could ask him to give you a few days heads up before he changes his site. Another option is to simply ask from the site owner access to his raw data- if it's stored in a mysql db you could ask for a user that can retrieve data only, or if it's stored in some XML format you could ask access to that (this way you won't need to connect and grab the data in the ways suggested before by badbad and myself thus your scripts would run faster and more efficiently). If you have permission to copy the data, I think you could ask for access to the data itself, avoiding the whole inconvenience of cases like you've suggested and more importantly- connecting and manipulating the data in the ways we suggested can be slow and a bit inefficient. Orio.
  17. Try it this way: <?php if($pagenum === "last") { $query = "Select COUNT(*) as C from forumtutorial_posts where parentid='$id'"; $result = mysql_query($query); $data = mysql_fetch_array($result); $pagenum = floor($data['C'] / $page_rows) + 1; } $pagenum = (is_numeric($pagenum) && $pagenum >= 1) ? (int)$pagenum : 1; $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; ?> The thing is that you haven't validated $pagenum - you haven't made sure it is a valid integer. I've added intval() to solve that in the previous script, but for some reason (I guess) it didn't function as expected. I think this should work, give it a try. Orio.
  18. I think this should do.. Change the line defining max into: <?php if($pagenum === "last") { $query = "Select COUNT(*) as C from forumtutorial_posts where parentid='$id'"; $result = mysql_query($query); $data = mysql_fetch_array($result); $pagenum = floor($data['C'] / $page_rows) + 1; } $pagenum = intval($pagenum); $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; ?>> Orio.
  19. lol If you want to buy facebook.co.cc you'd have to pay $854 per year. Orio.
  20. How could it be a security risk? If one receives his own input, and no one else is exposed to whatever he had entered, I can't see what harm could be done. Orio.
  21. You could get the contents of a page using file_get_contents() or if you need more power (cookies/post data etc') you could use cURL to get the data. From there it's all about string manipulation- preg_match()'s to fetch the data you need from the source code, and then all you need is to output it the way you want it. Orio.
  22. It's not a security risk, but it can mess up your design. Because only the user that posted the invalid data will see it (other people won't get the invalid input on their browsers), there's no XSS risk here. But I think it is problematic that the rest of your page will be shown in bold/red/etc. Just pass the data through htmlentities() before outputting it. Orio.
  23. Why don't you add an option that if $_GET['pagenum'] is set to the string "last" or to the integer 0 (Simply choose something and be consistent with it) it'd send you to the last page? This way you don't have to make a query in your sidebar for each thread to find out how many pages are there. You'll leave the work to the script that shows the thread. Orio.
  24. From what I've tested, this works. I don't understand- what's the problem? Orio.
×
×
  • 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.