Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. The above description is essentially what a database engine does for you without you needing to write and test any code. If your database is properly designed and with appropriate table indexes and you are using the database engine to do the searching, you can expect a database driven solution to operate faster than a flat file solution. You should first probably find out why your database searches are taking that long.
  2. fseek is the only method of randomly accessing data in a file (unless you can read the whole file into an array.) To use fseek to accomplish pagination, you would either need to maintain an 'index' of your file with the starting position of each line so that you can easily find where each line is at or you need to make every line the same length so that you can calculate the starting position of each line. Edit: If the make each entry in the index file the same length, you can easily and simply calculate where to fseek into the index file to find the start/end positions of the data you want in the data file.
  3. You can use preg_replace to do this. The following can be modified to do what you are asking - <?php $str = "this is my test string and string is very long with so many words"; $search = "my|string|with|words"; $str = preg_replace("/($search)/is","<a href='/index.php?word=$1'>$1</a>",$str); echo $str; ?> $search in the above can be produced by imploding your $words array using the '|' character.
  4. An example of how you can remove a filter - <?php // if the filter is present in the query-string, make a 'remove' link that will request the current page without that choice. $filter = Array("demo","demo2","demo3"); foreach($filter as $choice){ if(isset($_GET[$choice])){ $get = $_GET; // make a copy of the GET keys/values unset($get[$choice]); // remove the choice from the get keys/values $remove_links[] = "<a href='?".http_build_query($get, '', '&')."'>$choice</a>"; // make a link w/o the choice } } if(!empty($remove_links)){ // build the 'remove' navigation $remove_nav = "Remove Filter: " . implode(' | ',$remove_links); } ?> <html> <head> <meta charset="UTF-8"> <title>Filter example</title> <style type="text/css"> </style> </head> <body> <div> <?php echo isset($remove_nav) ? $remove_nav : ''; ?> </div> <div> <p>Other content on your page...</p> </div> </body> </html>
  5. You also have far far too much code and variables. The following is equivalent to the original code you posted - <?php $user = "S U O M I"; $user1 = "Tezz"; if(isset($_GET['user'])) { if(!empty($_GET['user'])) { $user = $_GET['user']; } } if(isset($_GET['user1'])) { if(!empty($_GET['user1'])) { $user1 = $_GET['user1']; } } //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); foreach($get as $key => $value){ $get[$key] = explode(',',$value); } $get1 = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user1"); $get1 = explode("\n", $get1); foreach($get1 as $key => $value){ $get1[$key] = explode(',',$value); } echo "<table border='1' cellpadding='5'>"; echo "<tr>"; echo "<td colspan='4'><b><center>".strtoupper($user)."</center></b></td>"; echo "<td></td>"; echo "<td colspan='4'><b><center>".strtoupper($user1)."</center></b></td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "<td></td>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "</tr>"; // loop over values foreach ($order as $key => $value) // 0-26, Overall-Dungeoneering { echo "<tr>"; echo "<td><b>$value</b></td>"; echo "<td>";if($get[$key][0]<=-1){echo "Not Ranked";}else{echo $get[$key][0];} echo "</td>"; echo "<td>".$get[$key][1]."</td>"; echo "<td>".$get[$key][2]."</td>"; echo "<td>"; if ($get[$key][2] == $get1[$key][2]){ echo "<img src='images/equal.png' />"; } elseif ($get[$key][2] <= $get1[$key][2]){ echo "<img src='images/downArrow.png' />"; } elseif ($get[$key][2] >= $get1[$key][2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>$value</b></td>"; echo "<td>";if($get1[$key][0]<=-1){echo "Not Ranked";}else{echo $get1[$key][0];} echo "</td>"; echo "<td>".$get1[$key][1]."</td>"; echo "<td>".$get1[$key][2]."</td>"; echo "</tr>"; } echo "</table>"; ?>
  6. Does that site have a separate method of testing if a user exists? If so, you should first check if the user is valid before trying to retrieve the data for that user. If not, file_get_contents returns a FALSE value on failure. You need to do two things - 1) display_errors should be set to OFF on a live server, so that php detected errors are not displayed. 2) Your logic should test if a FALSE value is returned and output an appropriate error message, such as 'Could not retrieve data for the username.'
  7. <?php= isn't anything that php understands. Use - <input name="name" type="text" id="name" value="<?php echo $fields['name']; ?>">
  8. You can do this all in your query statement - SELECT * FROM your_table WHERE A_dte <= DATE_ADD(NOW(), INTERVAL 90 DAY) However, what exactly are you trying to match, because you are forming a date 90 days into the future, then finding the rows that have a date less-than or equal to that value?
  9. If you look at what the query echoed as, you would see that the variable holding the date is empty or non-existent and you would need to troubleshoot why. Do you have error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed? You should be developing and debugging php code with these two settings to get php to help you.
  10. What does echoing $sql show?
  11. You would need to post your query that is failing (I'll guess it is missing single-quotes around the literal date being put into it via a php variable.) For your 7 days of data, you would execute ONE query that gets all the data you are interested in, then just detect the date change as you are iterating over the data to close out one table and start the next.
  12. Is display_errors ON? If you browse directly to the URL being requested by the ajax, do you get the error displayed? Unless your ajax code literally puts everything that comes back with the http response into the HTML of the page, the browser won't render anything and you won't see any php produced errors.
  13. You are missing the id in the query-string part of the URL - ?id=value
  14. Just remove that key/value from the $_GET array and rebuild the query-string part of the URL from the remaining $_GET keys/values. See http_build_query <?php unset($_GET['memory']); echo "<a href='?" . http_build_query($_GET, '', '&') . "'>Some text here...</a>";
  15. Textarea's don't have value="..." attributes. You put the text in between the opening and closing tags - <textarea>Existing text goes here...</textarea>
  16. Your page contains 41 markup errors - http://validator.w3.org/check?uri=http%3A%2F%2Fwww.game4vids.com%2Findex.php&charset=%28detect+automatically%29&doctype=Inline&group=0 You cannot even attempt to test your page in different browsers until the markup is error free.
  17. Because that specific data has some significance to your code that is responsible for outputting the content on the page. Without knowing what the code is, it is impossible to help you.
  18. Having output_buffering on in the php.ini or using output buffering in your script will hide any php errors that are output to the browser if you are doing a header() redirect on the page. The 500 error could have been in response to the page that redirected to, not the original page request.
  19. ^^^ That won't work for two reasons - 1) It results in invalid HTML and only certain browsers submit the display text when the value attribute is not present. 2) The display text is not just the name, so in the browsers where this would submit a value, it would take extra processing in the php code to get just the name out of the value. @Dusaro, what ever table column you use, you must be consistent throughout all your code. You started by using the ID as the value in the form's select menu options. You must have had a plan to use the ID or you wouldn't have written the code to do that.
  20. Someone already guessed what is causing the problem - You are using $news to hold the result from a mysql_query() statement. It is no longer the connection resource after that point in your code. The names you use for variables should indicate the purpose of that variable. As already stated, $news is not a good name for a mysql connection.
  21. $news is not a valid MySQL-Link resource and you would need to troubleshoot why it is not. It's either not getting set at all or it is not getting set to the result of a mysql_connect() statement. I would recommend using a better name for a database connection variable than $news. It's fairly likely that you are using $news for some other purpose in your script and the connection resource got overwritten.
  22. Your select menu's name attribute is 'member' <select name="member">. You would need to reference $_POST['member'] to get the value that was selected. Your original <option tags had a value='...' attribute. That is what you should use and since the values were the ID, you should use the ID column in the WHERE clause in your UPDATE query, not the name column.
  23. $formatted_number = number_format($your_value);
  24. You are probably either getting a fatal php parse error (usually caused by using short-open tags in your code) or you are getting a fatal php runtime error. Set error_reporting to E_ALL and either set display_errors to ON (causes errors to be sent to the browser) or set log_errors to ON (causes errors to be sent to the error log file.) For a fatal parse error in your main file, you will need to set those settings either in the master php.ini, in a local php.ini (when php is running as a cgi application) or in a .htaccess file (when php is running as an Apache Module.) For all other errors, you can set those settings in the code in your main file.
  25. All indications are that something in your actual full code, after the point where the DisplayPosts() method gets called up to where you decide to output anything on the page, is either die'ing or skipping over everything due to a false conditional statement or a false loop condition. I'm going to guess that you have some code that displays a short part of a long post with a 'more' link and that there's a length comparison that is coded wrong. P.S. You cannot return a value/string in the constructor of a class and your forum class doesn't have a $display property/variable so all the code that makes use of $this->display won't do anything.
×
×
  • 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.