Jump to content


Member Since 06 May 2003
Offline Last Active Yesterday, 05:32 PM

#1515933 Replace Characters Algorithm with O(n) Time/Complexity Notation

Posted by gizmola on 09 July 2015 - 01:13 AM

Seems like the mystery is solved.  Nice thread guys!

#1514157 Empty $_POST on form submission?

Posted by gizmola on 17 June 2015 - 08:38 AM

In the future, the fact that you were doing this as a wordpress customization would have been good to know.

#1509180 how to make my website fast ?

Posted by gizmola on 16 April 2015 - 04:45 PM

Neil, you left out:


  • Make a sandwich
  • Take power nap
  • $$$ Profit!

#1508998 URGENT: I could use 5 minutes of your time! Please read

Posted by gizmola on 14 April 2015 - 04:52 AM

Over a decade of involvement with phpFreaks, I have answered something like ten thousand questions, moderated thousands more, written a number of tutorials and spent days of my life providing system administration help. I've also personally donated a few hundred dollars over the years to help keep the site running. I'm just one of many volunteers who have done as much or more.

Many people don't understand that the people who make this place run are all volunteers who do what we do for the love of the PHP language, web development and open source ecosystem, and this is a way we can give back in our own small way.

With that said, for the first time in my many years here, I have a personal request.

My son plays Ice Hockey at our local rink in Burbank California. There aren't many rinks in this area, and Pickwick is one of the older rinks, having been built in the 1950's.

We love the sport, and the rink, but it has seen better days. The compression system doesn't work very well, the boards need repairs, and the facilities in general are not in great shape.

Kraft has a Hockeyville contest that is providing money to community hockey rinks for maintenance and upgrades, and Pickwick is a finalist. We are now looking to advance to the semi finals.

If this community has helped you, I'm asking that you simply go to this site and vote for our rink "Pickwick". You do have to register (Facebook makes it easy) or you can text. You have to be a US resident to do this.

You can call, text or use the website, and can vote up to 50x via each method.

If you've ever felt an interest in thanking me, or the folks who keep the site humming, here's a way you can do so that will only cost a few minutes of your time and nothing more.

You literally have to do this TODAY Tuesday April 13th EST. Voting is open as we speak!

Here's the Link: https://www.krafthockeyville.com/#

Choose Pickwick form the West column. THANK YOU.

Here's some information on other ways to vote if you are willing:


#1508590 scandir()

Posted by gizmola on 09 April 2015 - 04:52 PM

Thanks Barand -- I should have said "practically".  


Also more good reasons why people use echo instead.

#1508588 if (isset($_SESSION['un']) && isset($_SESSION[...

Posted by gizmola on 09 April 2015 - 04:46 PM

Yes, http://php.net/manua...okie-params.php can be issued in the code.  The problem is that you will need this call to occur just before the session_start() call.


Hopefully your system has that occur in a shared class, function or included file where you can make the change and have it seen throughout the scripts.


You might already have surmised that sessions depend on cookies, and this is really a mechanism of how cookies work and the built in protections.


You can do some investigation in advance of trying this, by looking at your cookies and seeing what the specific cookie(s) are that are being pushed from your server to determine if this might be the problem or not.

#1508581 scandir()

Posted by gizmola on 09 April 2015 - 03:43 PM

Great.  Also just a tip, Print and echo are the same function.  Most people use echo, because it's shorter.  


Printf came over from the 'C' language  and uses formatting placeholders and parameters.  There are some cases when you want to control things like the exact format of a number where printf can be attractive, although there are often a number of different ways to accomplish the same thing in php, and for the most part it's personal preference.

#1496425 What's the fastest way to search INNODB tables?

Posted by gizmola on 12 November 2014 - 07:33 PM

MySQL is an odd database because it has pluggable engines that can work entirely differently.  MyISAM is the base engine and of course InnoDB was a pluggable engine that became very popular.  


Just about all DB's have some form of caching for queries.  In the case of MyISAM this extends to the parsing of the queries themselves but not the actual data.  With the buffer_pool in innodb -- the actual data retrieved is cached.  So, in terms of what you were asking, when you do a LIKE '%...' query, the table will have to be scanned starting at row 1 and continuing to the last row in order to return a result.  With Innodb and a large enough buffer pool, essentially the data will already be in memory and the tablescan process will be much faster than it would be reading the data from disk.


Unfortunately, with shared hosting, you are not in control of those parameters as you're sharing a mysql server your hosting company provides, either on your server or some secondary server they host.


In the shared host scenario, I would advise you to implement Barand's suggestion.  

#1495852 What's the fastest way to search INNODB tables?

Posted by gizmola on 05 November 2014 - 08:00 PM

There are other reasons to utilize innodb besides the ones mentioned.  I highly recommend you stay with it.  


You could use Barand's suggestion -- have a denormalized search table, where you simply replicate the values into a small myisam table for the benefit of the search.   The coding and interruption required would be minimal. You'd simply need to write the replication script and schedule it in cron.  


To your original question one of the benefits of innodb is that it has a true data cache.  It's called the "buffer pool".  If you have sufficient resources on your server, you could increase the size of the buffer pool to insure that data is coming from cache.  It is often possible with a small fairly stable database like the one you describe where you are almost entirely "READ/SELECT" based, to have a pool where the data and indexes for the entire table will be in the buffer pool.  


At that point a SELECT '%...' will be far less disruptive than normally because it will be coming from memory.  An 8-10k row table is tiny in the database world.


You would have to invest some time trying to figure out the size of your overall database and the tables in particular, and you'd need to understand your overall memory usage to determine if you could allocate more RAM to mysql that you currently do.


You can start by looking at http://dev.mysql.com...uffer-pool.html


The innodb_buffer_pool_size and innodb_buffer_pool_instances are the only params you really need to understand and possibly change.   Whatever you do, these are good params to understand.  Although it might be a stretch if you are a novice sysadmin, the free tool, innotop is fantastic for making it easy to monitor the effectiveness of your caching and figuring out your cache hit ratio.  I would think based on your description that you should be aiming for close to 100% cache hit with your innodb tables.

#1493606 Struggling To Get Vanity URL's To Work

Posted by gizmola on 15 October 2014 - 03:40 PM

Make sure all the static resources (css, javascript, images etc) are using a fully qualified url, rather than a relative path and that will go away.

#1488073 Got great help here, but having trouble implementing?

Posted by gizmola on 17 August 2014 - 09:57 PM

I just flat out love you guys.  :-*




I just cannot thank you enough.  This is the kindest forum, to date, I've sought any kind of help from. 


Glad you got things working, and the words of thanks for the members who tirelessly help people out, are much appreciated, and rarely acknowledged.

#1487922 Got great help here, but having trouble implementing?

Posted by gizmola on 16 August 2014 - 04:03 AM

Hi Izzy.

I don't want to sound like a wet blanket, especially since this isn't actually addressing your question, but at this point we really have to insist that EVERYONE needs to convert their mysql_ code to either mysqli_ or PDO/Mysql. The entire mysql_ library is deprecated and will be removed entirely from php in the near future.

There is no point in us helping you debug code that is already obsolete when you write it. You should be using either mysqli or PDO, and with bind variables it is a game changer in terms of escaping (you don't need to) and the elimination of SQL injection exploits.

Also FWIW, I don't see anyplace where you are doing a SQL INSERT or implementing a form, so I'm not sure what you mean by "nothing added".

#1485376 Invalid parameter number: number of bound variables does not match number of...

Posted by gizmola on 15 July 2014 - 09:14 PM

More mysql syntax nonsense. Even if it's valid let's pretend it isn't and just use the standard syntax that all other RDBMS's use. ;)

#1482881 Installing PHP on iMac

Posted by gizmola on 19 June 2014 - 02:59 AM

This pretty much covers the way I've upgraded php and other components of a MAMP stack under osx  -> https://trac.macport...wiki/howto/MAMP


As an alternative, let me suggest investigating a few vagrants.  Pretty much any lamp or nginx based distro of your choosing could be located, or there are some pre-packaged vagrants you could try, that popped up in google:






Vagrant is a great way to develop without having to mess with your host OS.  The only issue I have had in the past is that sometimes composer can be hinkey under virtual box, but I'd still recommend looking into it.

#1478489 select distinct variable and another variable

Posted by gizmola on 06 May 2014 - 09:04 PM

All I can guess is that you want a list of distinct area/location combinations?

SELECT DISTINCT area,location FROM property
You can also accomplish this with GROUP BY

SELECT area, location FROM property
GROUP BY area, location