Skip to content

Instantly share code, notes, and snippets.

<?php
//connect to the xml and create an xml object from it
$session = curl_init('http://www.chinabuye.com/mivec/rss/data/apple.xml');
curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
$xml = new SimpleXMLElement(curl_exec($session));
//craete the csv file
$apple = "apple.csv";
$handle = fopen($apple, 'a');
<?php
//create a PDO object to interface with the database
try {
$dbh = new PDO('mysql:localhost:3306', 'root', '');
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
<?php
echo ' <link href="common/style.css" rel="stylesheet" type="text/css" />';
echo "<body onLoad='document.getElementById('song').select();'>";
//create a PDO object to interface with the database
try {
$dbh = new PDO('mysql:localhost:3306', 'root', '');
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
try{
$dbh->exec("USE isp5;");
$order = 'song';
$sth = $dbh->prepare("SELECT * FROM songs ORDER BY $order");
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
echo "<form action='' method='POST'>";
echo "<table><tr><th><a href=''>Song</a></th><th><a href=''>Artist</a></th><th><a href=''>Votes</a></th><th></th></tr>";
foreach($result as $r){
<?php
echo ' <link href="common/style.css" rel="stylesheet" type="text/css" />';
echo "<body onLoad='document.getElementById('song').select();'>";
//create a PDO object to interface with the database
try {
$dbh = new PDO('mysql:localhost:3306', 'root', '');
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
<?php
echo ' <link href="common/style.css" rel="stylesheet" type="text/css" />';
echo "<body onLoad='document.getElementById('song').select();'>";
//create a PDO object to interface with the database
try {
$dbh = new PDO('mysql:localhost:3306', 'root', '');
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
$state=array(song=>FALSE, artist=>FALSE, votes=>FALSE);
$order = 'song';
if (isset($_GET['order'])){
$order = $_GET['order'];
echo $order;
echo $state[$order];
$state[$order]=!$state[$order];
}
$state=array('song'=>'FALSE', 'artist'=>'FALSE', 'votes'=>'FALSE');
$order = 'song';
if (isset($_GET['order'])){
$order = $_GET['order'];
echo $state[$order]." ";
$state[$order] = ! $state[$order];
echo $state[$order]." ";
}
<?php
require('lotto.Class.php');
$handle = new lotto();
$handle->printpick3();
?>
<?php
Class lotto{
require('File.Class.php');
function init(){
$dbName = lotto;
try {