Skip to content

Instantly share code, notes, and snippets.

@rantastic
rantastic / php_error_reporting.php
Created May 9, 2013 14:38
PHP: Error reporting
/////////////ERROR REPORTING
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
/////////////ERROR REPORTING
@rantastic
rantastic / fadeOut_remove.js
Created April 16, 2013 15:05
JS: jquery fadeout and remove
$('element').fadeOut('slow',function(){$('this').remove();});
@rantastic
rantastic / datetime.php
Created April 12, 2013 23:19
PHP: Datetime date format
$date = date('Y-m-d H:i:s');
@rantastic
rantastic / grab_image.php
Created April 11, 2013 15:24
PHP: Save image from URL
function grab_image($url,$saveto){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$raw=curl_exec($ch);
curl_close ($ch);
if(file_exists($saveto)){
unlink($saveto);
}
@rantastic
rantastic / simple_curl.php
Created April 11, 2013 15:23
PHP: Simple CURL
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$a = curl_exec($ch);
$youtubeJSON=json_decode($a,true);
@rantastic
rantastic / jquery_post.js
Created April 3, 2013 15:13
JS: jquery post
$.post('ajax/PAGE', postData,
function(data){
},
'json');
@rantastic
rantastic / bootstrap_modal.html
Created March 26, 2013 21:39
HTML: Bootstrap modal
<div id="registerModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
@rantastic
rantastic / pdo_update_single.php
Created March 21, 2013 20:37
PHP: PDO update single
$stmt = $db->prepare("UPDATE tablename SET tableRow = ?, tableRow2 = ? WHERE tableRow3 = ?");
$stmt->execute(array($var1,$var2,$var3));
if($stmt->rowCount()>0){
}
@rantastic
rantastic / pdo_insert_single.php
Created March 21, 2013 20:34
PHP: PDO insert single
$stmt = $db->prepare("INSERT INTO tablename (var1, var2, var3) VALUES (?,?,?)");
$stmt->execute(array($var1,$var2,$var3));
if($stmt->rowCount()>0){
}
@rantastic
rantastic / pdo_select.php
Created March 21, 2013 18:55
PHP: PDO select statement return array
$stmt = $db->prepare('SELECT * FROM tablename WHERE colname = ?');
$stmt->execute(array($variable));
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0){
foreach($results as $result){
}
}