How To Display Rows From MySQL Using PHP And Smarty v2

Author: , Posted on Friday, January 27th, 2012 at 1:58:30pm

The PHP

1
2
3
4
5
6
7
8
9
$sql = 'select * from yourTable';
$result = mysql_query($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
   $rows[]   = $row;
}
$page   = new Smarty();
$page->assign('rows', $rows);
$page->show('yourTemplate.php');
$sql = 'select * from yourTable';
$result = mysql_query($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
   $rows[]   = $row;
}
$page   = new Smarty();
$page->assign('rows', $rows);
$page->show('yourTemplate.php');

The Smarty Template

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{if $rows}
 
   {section name=row loop=$rows}
      {foreach from=$rows[row] key="Key" item="Value"}
 
{$Key}: {$Value}
 
      {/foreach}
  {/section}
 
{else}
<h1>NO OFFERS FOUND</h1>
 
{/if}
{if $rows}

   {section name=row loop=$rows}
      {foreach from=$rows[row] key="Key" item="Value"}

{$Key}: {$Value}

      {/foreach}
  {/section}

{else}
<h1>NO OFFERS FOUND</h1>

{/if}

How To Fix Broken Boot After Yum Update On Amazon Linux

Author: , Posted on Friday, January 20th, 2012 at 11:06:14am

Stop the instance first…YMMV:

1
2
3
4
5
yourHost# ec2-describe-images describe-images -o amazon --filter "manifest-location=*pv-grub-hd0_1.02-i386*" --region us-east-1
IMAGE   aki-805ea7e9    ec2-public-images/pv-grub-hd0_1.02-i386.gz.manifest.xml amazon  available   public      i386    kernel              instance-store  paravirtual xen
 
yourHost# ec2-modify-instance-attribute --kernel aki-805ea7e9 --region us-east-1 i-39764XXX
kernel  i-39764XXX  aki-805ea7e9
yourHost# ec2-describe-images describe-images -o amazon --filter "manifest-location=*pv-grub-hd0_1.02-i386*" --region us-east-1
IMAGE	aki-805ea7e9	ec2-public-images/pv-grub-hd0_1.02-i386.gz.manifest.xml	amazon	available	public		i386	kernel				instance-store	paravirtual	xen

yourHost# ec2-modify-instance-attribute --kernel aki-805ea7e9 --region us-east-1 i-39764XXX
kernel	i-39764XXX	aki-805ea7e9

http://aws.amazon.com/amazon-linux-ami/latest-release-notes/

How To Call Functions Within Classes Dynamically In PHP

Author: , Posted on Thursday, January 19th, 2012 at 11:12:55am
1
2
3
4
5
6
7
8
9
    public function valid($function = '') {
        $methodVariable = array($this, $function);
        if (is_callable($methodVariable)) {
            return $this->{$function}();
        } else {
            $this->msgs[]   = "Validation method $function is unavailable!";
            return 0;
        }
    }
    public function valid($function = '') {
        $methodVariable = array($this, $function);
        if (is_callable($methodVariable)) {
            return $this->{$function}();
        } else {
            $this->msgs[]   = "Validation method $function is unavailable!";
            return 0;
        }
    }

How To Install MongoDB Via Yum On CentOS/Amazon Linux

Author: , Posted on Wednesday, January 18th, 2012 at 10:28:34am

Procedure

1
2
3
4
5
6
7
8
9
vim  /etc/yum.repos.d/10gen.repo
yum install mongo-10gen mongo-10gen-server
vim /etc/mongod.conf - set dbpath variable
mkdir /volumes/data/mongo
chown mongod:mongod /volumes/data/mongo
chmod 2775 /volumes/data/mongo
chkconfig mongod on
service mongod start
pecl install mongo
vim  /etc/yum.repos.d/10gen.repo
yum install mongo-10gen mongo-10gen-server
vim /etc/mongod.conf - set dbpath variable
mkdir /volumes/data/mongo
chown mongod:mongod /volumes/data/mongo
chmod 2775 /volumes/data/mongo
chkconfig mongod on
service mongod start
pecl install mongo

/etc/yum.repos.d/10gen.repo

For 64-bit:

1
2
3
4
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

For 32-bit:

1
2
3
4
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

Resource Links

http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages

http://www.if-not-true-then-false.com/2010/install-mongodb-on-fedora-centos-red-hat-rhel/

http://devzone.zend.com/1730/getting-started-with-mongodb-and-php/

How To Escape Newlines In PHP For Javascript

Author: , Posted on Wednesday, January 11th, 2012 at 7:39:54pm

You must use all three lines together for it to work…YMMV:

1
2
3
$escaped = str_replace(chr(10),'\n',$original_value);
$escaped = str_replace(chr(13),'\r',$escaped);
$escaped = preg_replace("/(\r?\n)/","\n",$escaped);
$escaped = str_replace(chr(10),'\n',$original_value);
$escaped = str_replace(chr(13),'\r',$escaped);
$escaped = preg_replace("/(\r?\n)/","\n",$escaped);

WebThriftStore and the ASPCA Join Forces

Author: , Posted on Thursday, January 5th, 2012 at 8:58:31pm

http://www.aspca.org/blog/web-thrift-store.aspx

Happy New Year 2012

Author: , Posted on Saturday, December 31st, 2011 at 6:07:01pm

How To Install ec2-consistent-snapshot On AWS/CentOS

Author: , Posted on Friday, December 30th, 2011 at 12:35:12pm
1
2
3
yum --enablerepo=epel install perl-Net-Amazon-EC2 perl-File-Slurp perl-DBI perl-DBD-MySQL perl-Net-SSLeay perl-IO-Socket-SSL perl-Time-HiRes perl-Params-Validate ca-certificates
wget -O /opt/aws/bin/ec2-consistent-snapshot http://bazaar.launchpad.net/~alestic/ec2-consistent-snapshot/trunk/download/head:/ec2consistentsnapsho-20090928015038-9m9x0fc4yoy54g4j-1/ec2-consistent-snapshot
chmod 0775 /opt/aws/bin/ec2-consistent-snapshot
yum --enablerepo=epel install perl-Net-Amazon-EC2 perl-File-Slurp perl-DBI perl-DBD-MySQL perl-Net-SSLeay perl-IO-Socket-SSL perl-Time-HiRes perl-Params-Validate ca-certificates
wget -O /opt/aws/bin/ec2-consistent-snapshot http://bazaar.launchpad.net/~alestic/ec2-consistent-snapshot/trunk/download/head:/ec2consistentsnapsho-20090928015038-9m9x0fc4yoy54g4j-1/ec2-consistent-snapshot
chmod 0775 /opt/aws/bin/ec2-consistent-snapshot

http://alestic.com/2009/09/ec2-consistent-snapshot
http://www.thatsgeeky.com/2011/05/ec2-consistent-snapshot-on-amazons-linux-ami/
http://www.thatsgeeky.com/2011/06/rotating-ebs-snapshots-ec2-prune-snapshots/

How To Block Spam Text Messages On Your AT&T iPhone

Author: , Posted on Thursday, December 29th, 2011 at 1:06:52pm

If the spam comes from an actual phone number you can report the number directly to AT&T…

  1. Tap and hold the body of the text message, then choose Copy.
  2. Create a new text message to 7726 (SPAM on the keypad).
  3. Paste in the spam message you just copied and send it.
    Note: Sending this message won’t cost you anything, nor will the replies from AT&T.
  4. AT&T will send you a thank-you message and ask you to reply with the phone number of the sender.
  5. Type in the phone number that sent the spam in the first place and hit Send.

Original Post on CNET: http://reviews.cnet.com/8301-19512_7-20102542-233/how-to-block-text-message-spam-on-your-iphone-at-t/

A Blessed Yule To All

Author: , Posted on Saturday, December 24th, 2011 at 11:20:28am