IThinkMyBrainHurts
Members-
Posts
51 -
Joined
-
Last visited
-
Days Won
1
Everything posted by IThinkMyBrainHurts
-
Java or C++ with PHP?
IThinkMyBrainHurts replied to mostafatalebi's topic in Other Programming Languages
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!? -
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...
-
lol, cheers, just advert answering anyway
-
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>"; }
-
Need more insight on caching when pagination is involved
IThinkMyBrainHurts replied to mouseywings's topic in PHP Coding Help
You are aware of the LIMIT keyword in databases? -
Need more insight on caching when pagination is involved
IThinkMyBrainHurts replied to mouseywings's topic in PHP Coding Help
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... -
need to refine the OOP PDO prepared statement
IThinkMyBrainHurts replied to Supervan's topic in PHP Coding Help
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; } } -
Need more insight on caching when pagination is involved
IThinkMyBrainHurts replied to mouseywings's topic in PHP Coding Help
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??? -
Capture website code and send to PHP
IThinkMyBrainHurts replied to 7blake's topic in PHP Coding Help
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 -
Need more insight on caching when pagination is involved
IThinkMyBrainHurts replied to mouseywings's topic in PHP Coding Help
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...!? -
Undefined error and checkout adding more items!
IThinkMyBrainHurts replied to aboyce2107's topic in PHP Coding Help
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!!! -
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
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 -
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
Can I see the latest index.php please? -
Is that in a loop, else $optid is redundant... AFAIK str_repeat() just repeats a string, nothing special.
-
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
The error message is exactly the same? -
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
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/ -
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...
-
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
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...!? -
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.
-
Header already sent error message on LIVE server
IThinkMyBrainHurts replied to thara's topic in PHP Coding Help
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. -
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
-
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
-
Problem fixing "Warning: Cannot modify header information"
IThinkMyBrainHurts replied to A JM's topic in PHP Coding Help
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? -
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