Jump to content


Member Since 06 May 2003
Offline Last Active Oct 24 2014 01:19 PM

#1493606 Struggling To Get Vanity URL's To Work

Posted by gizmola on 15 October 2014 - 10:40 AM

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 - 04: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 15 August 2014 - 11:03 PM

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 - 04: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 18 June 2014 - 09:59 PM

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 - 04: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

#1478480 PHP Send Mail

Posted by gizmola on 06 May 2014 - 03:32 PM

I don't plan to beat a dead horse. You state you have code working, but what you actually are doing is sending 2 separate emails.

Here's some info for you:

Calling the mail function.

Calling the mail function, but SUPPRESSING errors (because the @ was used at the front of the function call name). Now if mail was to return an error, you will never see it.

Your code, sending 2 separate emails:

@mail($email_to, $email_subject, $email_message, $headers );
@mail($email_from, $email_subject, $email_message, $headers );
People advised you that all you really needed to do was provide a string that contained a comma separated list ("email1, email2").

What you should have done:

// send one email to both recipient and sender.

mail($email_to . ',' . $email_from,  $email_subject, $email_message, $headers);
Of course the best way to do this would probably be to send yourself a bcc: copy instead.

I also don't know if you understand this or not, but this form is basically an open door allowing anyone to spam anyone else using your site as the spam delivery mechanism. Writing a bot to take a database of people would be trivial. This is just an open invitation to getting yourself exploited for spam delivery, but something tells me your email may already be seen as spam only you just haven't figured that out yet. Sending email programmatically from a server requires quite a bit of knowledge about DNS, MTA's, SPF, DKIM and other things you probably aren't aware of.

#1478256 "Roster" Script

Posted by gizmola on 05 May 2014 - 12:03 PM

You might have more luck pinpointing specific classes/functions etc. that you think might have an issue or could be improved.

Speaking generally, it would be easier to maintain if you put the presentation code into "template" files that you include, or use a template engine for.

I'm not going to suggest any of the sophisticated compilation template engines like smarty or twig, due to the fact that you are integrating with bulletin, but take a look at these:

Blog post that shows a simple effective way could pull this off: http://chadminick.co...ate-engine.html

Some simple template classes that can be used with a simple include of their template class:


You might also look at breaking up a lot of the logic sections into functions, named appropriately to represent the specific purpose they fulfill.  That way if you decide to move things around or add or remove sections, it will be much easier for someone to understand the code and make changes.

#1475800 Banner ad Rotation

Posted by gizmola on 11 April 2014 - 02:39 PM

To make it database driven you simply need to create a banner table.

You'll want to have a structure like this:
id int (primary key)
url varchar(512)
image varchar(128)
active tinyint
As for rotation, so long as your banner ad table doesn't get larger than a thousand rows, there isn't much of a concern, however, I would highly recommend reading this blog post: http://jan.kneschke..../order-by-rand/

With that said, the simplest solution for you, that will certainly work fine for quite a while:
If you expect rotation over time without reloads, then cyberRobot's point should be taken into account. Often people will utilize an iframe and place the banner in the iframe, which can then have a simple meta refresh tag in the header of the code.

Ajax polling offers a more sophisticated option to cyberRobot's point, or you could alternatively fetch a number of ads initially and use a javascript timer to rotate them.

#1473739 New Moderator: mac_gyver

Posted by gizmola on 24 March 2014 - 03:00 PM

Congrats mac, agree with Phillip - you have really helped to keep phpf running, and your efforts are appreciated.

#1471661 Newbie Questions (EASY)

Posted by gizmola on 06 March 2014 - 12:47 PM

What have you tried?

I suggested that you:

Put the mail chimp code into a file named mailchimp.inc.php

There should NOT be a <?php at the top. Simply put that code exactly as is, in the file.

This file should be in the same directory as your template.

In the template add: include('mailchimp.inc.php');

#1471109 Hiring programmers, are there copyright laws?

Posted by gizmola on 28 February 2014 - 07:56 PM

right.. but the problem is with proving and enforcing it.

Agree 100%.

I've had these types of conversations with people probably 50x over the years, I have NEVER seen a case that didn't involve a patent.

Every other business person I talk to, who has an idea, is convinced their idea is amazing and original and worth a billion dollars.

#1468366 What's the use of abstract classes/methods?

Posted by gizmola on 10 February 2014 - 01:02 AM

There are times when you want to create a number of subclasses that all inherit from the same base class, but insure that the base class can not be instantiated itself.  A simple example would be a zoo simulation where you decide that you want to have a factory class that can "make" new animals.  When your application needs to create a new lion, for example, you don't want to have to write the same code over and over, when you can instead have completely generic code that creates animals of any type.


Once an animal object is created, you will probably need to call some standard methods, and again if you based all your specific animal classes off an abstract animal class, your non-abstract methods can be called.  Imagine you need some code that Will store an animal name, birthdate, gender and location in a table. You may decide that for each animal class you'll have a seperate table  with the same name as the class.  So in this example, you will have a lion table in the database.


In your abstract animal class you might have:

//Animal class.
public function saveNew() {
    $table = get_class($this);
    $this->db->$table->insert(array('name' => $this->name, 'birthdate' => $this->birthdate, 'location' => $this->location, 'gender' => $this->gender));

Needless to say, you will not have an 'animal' table, so making the baseclass abstract provides some protection against issues with saveNew(). 


It also provides a standard set of methods the factory class can depend on, so it can feature code like:

// Animal Factory class
public function makeAnimal($type, $location) {
    $animal = new $type($location);

This code can be depended upon to work for any animal class that inherits from 'Animal'.  setName() is an example where you might want to have an abstract method, assuming that the rules for animal names would be different for each different type of animal.  The factory class will call setName(), but it is up to you to actually write function setName() when you create each individual class. 


SetGender()_ is another example, where you might lookup the relative ratio of male to female animals in a table where each row is named by class.  While you would have a row for lion, elephant and crocodile, you'll have no row for animal.


When trying to really dig into these ideas, you'll quickly find yourself gravitating towards "Object oriented design patterns".  The books on this subject will provide specific examples that should help you understand why the oop features in php were implemented in ways that the manual does not. 

#1468004 Contact Form Not Working, any idea why?

Posted by gizmola on 06 February 2014 - 08:27 PM

mail() depends on the configuration of your specific server, and the underlying mail transfer agent mechanics.  I don't see anything obviously wrong with your code, although there could be something subtle.  If the mail() function is succeeding, you need to debug at the MTA level.  For example, if you were on a linux server and the mail is being dumped off to sendmail or postfix there are ways to determine if the mta is successfully delivering the mail.


Mail server configuration also includes details about DNS MX, SPF and DKIM, not to mention the core SMTP standard.  If you're just developing on a local workstation its probable that you don't have a working mail configuration OR you do have one, and the mail is being delivered, but due to the lack of the aforementioned environment, your mail is being spam filtered or outright rejected.

#1465239 MySQL Load Balancing between 2 or more servers?

Posted by gizmola on 14 January 2014 - 02:03 PM

MySQL really doesn't support load balancing for writes.  It does support slaves/replication for reads.  So the idea of putting a load balancer in front of a set of mysql servers isn't used from what I've seen.


I think what you're really looking for is:  http://dev.mysql.com...tion-howto.html


You can google for mysql replication and get more information. 

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime