Jump to content

IThinkMyBrainHurts

Members
  • Posts

    51
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by IThinkMyBrainHurts

  1. I believe PHP is a progression of C++, that said C++ and Java are very similar in coding style. Also C++ uses a whole lot of the same function names as PHP, which stems from the original C libraries. Java is very portable but, mmm very slow, C++ beats it hands down, hence why the majority of games are written in C++. As Requinix say's,it depends on what you want to do. If you're writing system programs, drivers, serious number cruncher's, simulators etc then it's C++ all the way. On the other hand if you want to write something once and quickly then Java is your bag, it's more akin to a bag of tricks. This bag of tricks is very adaptable and is being used for some very adaptable applications. From having a look at the job market recently, there seems to be a whole lot more C# job adverts than Java, in my area!?
  2. Hi, I'm after compiling a list of responsive menus that only use CSS, no JS allowed!!! Ideally they're to handle at least 3 levels, but 2 levels passable Cheers and hope you lot find this list useful too...
  3. lol, cheers, just advert answering anyway
  4. In your chatbox code, you set $id with something uninitialized / non-existent, so that will be null. $id=$rows['id']; Then you build the delete link, again with a null value. $dellink="<a href=\"delete.php?id=" . $id . "\"> Delete </a>"; Then you add the same link to all the items: while($row=mysql_fetch_array($result)){ //list the comments echo $row['name'] . "<br>" . $row['comment']."<br /> . $dellink .<br><hr>"; } In reality the link should be constructed in the loop where you can actually access the id! So something like this: while($row=mysql_fetch_array($result)){ echo $row['name'] . "<br>" . $row['comment']."<br /><a href=\"delete.php?id=" . $row['id'] . "\"> Delete </a><br><hr>"; }
  5. You are aware of the LIMIT keyword in databases?
  6. I don't get why you're caching them to file at all! Especially why get them all, store them again and then show some, why not just get some and dump 'em out to the client, much more efficient on the DB, file and PHP parser...
  7. The original is simplest in my view, however a wrapper class for this specific query could look like this (untested): class my_xyz_query{ private $id = null; private $name = null; private $parms = null; public function__construct($name="",$id=""){ $this->parms=array(); $this->parms[] = array(':id',$id,PDO::PARAM_INT); $this->parms[] = array(':name',$name,PDO::PARAM_STR); } public function set_name($name){ $this->name=$name; } public function set_id($id){ $this->id=$id; } public function get_parms(){ $this->parms[0][1]=$this->id; $this->parms[1][1]=$this->name; return $this->params; } }
  8. Well if you can't do it at that level then you'll have to either use the lookup method mentioned before or refactor it before storing in the txt file db thing you're using! A txt file, how are you parsing that? Is that optimal???
  9. Wouldn't this only get the Body section and not the whole page? var x = $("body").html();EDIT:Here's how to get the lot, depending on how much: http://stackoverflow.com/questions/982717/how-do-i-get-the-entire-pages-html-with-jquery
  10. You could build a separate array of keys and use that for access. However you'd have to build it. Which leads to... I may have another way but would be easier to see the get_posts() function! However, when you say cache, are you storing all these in a session variable? Else, you're retrieving it all again anyway...!?
  11. If that's all in a class then you'd access the variable using $this->storeID Oh, please edit your post and use code tags to wrap your code!!!
  12. 1. All worked for me, no errors 2. Followed latest URL and the the PHP in the HTML file wasn't being parsed! That probably means your server isn't configured to parse PHP within HTML files! - Simple solution, rename files to .php - Add the right AddType config, see examples here: http://stackoverflow.com/questions/6295141/server-not-parsing-html-as-php
  13. Can I see the latest index.php please?
  14. Is that in a loop, else $optid is redundant... AFAIK str_repeat() just repeats a string, nothing special.
  15. The error message is exactly the same?
  16. errrr... many ways... I'd suggest studying the MVC pattern, but a quick solution: Move the following: // Include the header file: include('./includes/header.inc.html'); to after the possible header() clause in the $page pages... e.g here: <?php // Check login status, If not redirect to login page if (!login_check($mysqli) == true) { $url = BASE_URL.BASE_URI.'index.php'; // Define the URL. header("Location: $url"); exit( ); // Quit the script. } // Include the header file: include('./includes/header.inc.html'); Others may suggest using ob_start and such. * In Wordpress themes, each page template use an include for the header section Why I suggest the MVC approach is because you work out all the bits of the Model before outputting the View. For instance, on page request you check the page request link, then handle any form bits (from the Controller, i.e. the response from the View), and then output the View. For more see the Application Design forum here on PHPFreaks: http://forums.phpfreaks.com/topic/20556-resources/ Also from that same page here's a link about how to use the cache (ob_start, etc): http://www.devshed.com/c/a/PHP/Output-Caching-with-PHP/
  17. If you look in the Codex here: https://codex.wordpress.org/Function_Reference/get_search_form and then scroll down to "Theme Form" and see the part where they add an extra hidden element to restrict the search...
  18. Yeah, so here: // Include the header file: include('./includes/header.inc.html'); // Include the content-specific module: // $page is determined from the above switch. include('./modules/' . $page); The header.inc.html gets included prior to the $page, so the header is always outputted first...!?
  19. How are these being used? Are they all in one file? If so, the use of "return" not within a function scope basically acts like exit...http://php.net/manual/en/function.return.php As Muddy_Funster demonstrates, use functions to wrap your code (that's when you normally use "return" statements).If you really do want to put them in separate files (but by sounds you want functions!) then use some form of include(), include_once(), require() or require_once() to include the file, anything not within a class or function will be executed straight away.
  20. Sounds like header.inc.html is included before _modify_admin_select.inc.php, therefore virtually of header.inc.html is outputted. If header.inc.html isn't supposed to be included prior then that's the issue.
  21. Starting from 5, the 3 is tested by the mod 3 later, 4 is not a prime. This part is neither here nor there really.The loop step size means that it makes 6 times fewer checks than the other version, and if you're testing say 104729 (the 10,000th prime), that's what 17,454 times more efficient, and that prime is tiny when it comes to public key encryption.*** Looks like it only makes it 3 times faster? http://en.wikipedia.org/wiki/Primality_test* My knowledge on the subject is over 10 years old now, also it was only a personal interest
  22. So... $ndir=str_replace('\\','/',rtrim(__DIR__,"nub")); // Pre PHP 5.3 use dirname(__FILE__) instead of __DIR__ Since Windows handles both path types, whereas Linux doesn't. This way the config file can be transferred easily without re-install! Cheers
  23. The JS is irrelevant server side it only operates client side. The output may come from an error!?! What is on line 82 of claim.php?
  24. lol, makes perfect sense, doh! However, that path is generated by __DIR__: $ndir=rtrim(__DIR__,"nub"); On searching i'm not seeing this issue mentioned... or output showing similar either??? Yes, Ican replace these manually, issue solved. However is this the expected behaviour of __DIR__ or ...? Cheers
×
×
  • 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.