Skip to content

Instantly share code, notes, and snippets.

View element121's full-sized avatar

element121 element121

  • UK
View GitHub Profile
@element121
element121 / LastRss_example.php
Last active December 9, 2015 23:16
How to parse / integrate a Wordpress.com blog RSS feed into a PHP page
// include lastRSS
include "lastRSS.phps";
// Create lastRSS object
$rss = new lastRSS;
// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = '';
$rss->cache_time = 0;
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 3.4.9
-- http://www.phpmyadmin.net
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Table structure for table `vehicle_makes_models_style`
--
-- This is MySQL sample provided from http://element121.com/2015/11/07/how-to-join-the-same-table-twice-in-a-single-sql-query-statement/
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 11, 2016 at 10:57 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
-- This is MySQL sample provided from http://element121.com/2016/02/02/how-to-join-the-same-table-three-times-in-a-single-sql-query-statement/
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 11, 2016 at 10:57 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
<?php
// PHP Code to add a member to a MailChimp list using their API v3.0
// As described in this blog post: http://element121.com/2016/04/30/how-to-add-a-subscriber-using-mailchimps-api-with-php/
// http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
/*
curl --request POST \
--url 'https://usX.api.mailchimp.com/3.0/lists/57afe96172/members' \
--user 'anystring:apikey' \
--header 'content-type: application/json' \
<?php
if (isset($_POST['email']))
{
// Grab the POSTed email address input field
$email = $_POST['email'];
// Use filter_var to check if the email address is valid
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
echo("$email is not a valid email address");
<?php
if (isset($_POST['number']))
{
// Grab the POSTed number input field
$number = $_POST['number'];
$number_range = $_POST['number_range'];
// Use filter_var to check if the value is a valid number
include('simple_html_dom.php');
// Call a remote file
$html = file_get_html("http://ww.site-to-scrape.com/page.php");
// Then access the DOM to find what you need, for example the title of the web page:
foreach($html->find('title') as $e)
{
echo $e->innertext . '<br>';
}
CREATE TABLE IF NOT EXISTS `gc_countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sequence` int(11) NOT NULL DEFAULT '0',
`name` varchar(128) COLLATE utf8_bin NOT NULL,
`iso_code_2` varchar(2) COLLATE utf8_bin NOT NULL DEFAULT '',
`iso_code_3` varchar(3) COLLATE utf8_bin NOT NULL DEFAULT '',
`address_format` text CHARACTER SET utf8 NOT NULL,
`postcode_required` int(1) NOT NULL DEFAULT '0',
`status` int(1) NOT NULL DEFAULT '1',