Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. By moving the directory outside of the website document root i.e # document root public_html # includes directory public_html/includes to # document root public_html # includes directory includes You can still include files from the includes directory in your scripts using the correct path however there is no access publically i.e http://www.xyz.com/includes
  2. Simple - use URL parameters. The paremeter is used in the WHERE condition after it has been validated: http://www.xyz.com/page.php?param=abc http://www.xyz.com/page.php?param=def <?php // page.php $result = mysql_query("SELECT * FROM table WHERE field='".mysql_real_escape_string($_GET['param'])."'"); ?>
  3. Look at PHPs simpleXML extension. You can parse the XML document.
  4. Bad method - file_get_contents() is slow If you want to check that the webpage exists then I would check the HTTP header. i.e if you get no header the site maybe dead. You may also get a 404 header for an invalid url. <?php // return header function httpHeader($url) { $urlParts = parse_url($url); $fp = @fsockopen($urlParts['host'],80,$errno,$errstr,20); $out = "GET ".$url." HTTP/1.1\r\n"; $out.= "Host: ".$urlParts['host']."\r\n"; $out.= "Connection: Close\r\n\r\n"; @fwrite($fp,$out); $content = @fgets($fp); return $content; } print httpHeader("http://google.com")."\n"; ?>
  5. This may take some processing becase of the number of queries needed. I suggest displaying all letters even if there a 0 rows. I would then display 0 results found after a search. However here is how you would do the initial question: <?php $range = range('a','z'); for($x = 0; $x < count($range); $x++) { $result = mysql_query("SELECT id FROM table WHERE topics_name LIKE '".$range[$x]."%'"); // destroy letter if no results found if(!mysql_num_rows($result)) { unset($range[$x]); } } // now loop your letters out foreach($range as $letter) { print $letter."<br />"; } ?>
  6. You may need to optimise your mysql configuration for the number of users (my.cnf). More memory in your server will also help. Are your tables properly optimised i.e. indexes setup correctly. Also setup a slow query log so you can see the offending queries. http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html
  7. Yes, your database structure should be designed to store the values of the user input i.e the answer chosen. This should be recorded after each submitted question to restore a previous session. You do not save objects to a database.
  8. The above code is not needed at all. 2 simple facts 1. If you are editing data from the database then the field will be prefilled with the database value 2. If the user resubmits the data and there is a form error you want the value of the $_POST array to remain in the field value rather than the database value. The initial shorthand if statement does just this
  9. $query = "SELECT * FROM vehicles LIMIT 10";
  10. We use these guys. Have both shared and dedicated servers. http://bpweb.net/
  11. You should use a session. You do not save an object to a database.
  12. Not quite. You may want the post value there if there are form errors <input type="text" name="hire_date" id="hire_date" value="<?php echo isset($_POST['hire_date']) ? $_POST['hire_date'] : $rows['hire_date'];?>" size="34" maxlength="50" />
  13. Wasn't aware of that thanks. However the Ajax call could initiate a server side script to post to a remote server.
  14. Javascript Sorry I haven't the time to install and test your code. If it is possible to post the current URL I could test.
  15. I use IE 8. The alert suggests you have an Ajax object. Your functions must be using unsupported methods. I would carefully debug your functions to check that the correct data is available within.
  16. Can you add an alert to check the http object exists alert(http) You haven't got javascript disabled have you?
  17. I don't think that a timeout is your issue. There is no such thing that is why you cannot find any information. If you get a blank page then the script must be terminating with an error but you haven't set your php configuration to display errors. Add these lines to the top of the script preferably in a common include to all pages: ini_set('display_errors', 1); ini_set('error_reporting', E_ALL & ~E_NOTICE);
  18. http://www.phplibrairies.com/tutorial_design-pattern_en.html
  19. Google has an API for this http://code.google.com/apis/ajaxsearch/
  20. Yes you can do this. If you wanted to process the form data on another server then the form action parameter would simply point at the page i.e. <form action="http://www.xyz.com/process.php" method="post"> However if you want to do it with ajax then I suggest the accepted method on the remote server is GET so: // Ajax method req.open("GET", http://www.xyz.com/process.php?var1="+val1+"&var2="+val2); With this method you can also store the data on both servers with a second ajax request whereas using the using the form action parameter will send a user to the remote server. You would have to redirect them back.
  21. This will catch any error function getHTTPObject() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript alert("XMLHttpRequest not supported"); return null; }; Create the http object within the JS function function requestInfo(url,id,redirectPage) { var http = getHTTPObject(); }
  22. impossible with a single query. build an array using your programming logic
  23. Its difficult for me to picture what you want the result set to look like. I'm guessing pk parent 1 0 2 1 3 1 4 0 5 4 6 4 7 0 8 7
  24. Do you not have an authors table? You would achieve this in the following mannor: SELECT a.author, COUNT(f.id) AS totalPosts FROM forum f LEFT JOIN authors a ON (a.authorId=f.authorId) WHERE f.threadId='123' GROUP BY a.authorId ORDER BY totalPosts DESC
  25. Not really. All depends on what you need to do with the results. Do you need to keep all results from all sites for reporting? If not why not after your spider has completed one site export and compress the database and then truncate it for the next.
×
×
  • 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.