www.clinde.de

www.clinde.de

www.clinde.de

www.clinde.de

www.clinde.de



Snippets



Snippet hinzufügen

PDO prepared statement bindpar
132015-01-07 22:54:23PHP
Edit this SnippetDelete this Snippet+1 upvote
$con = new PDO('mysql:host=localhost;dbname=devphpde_sqldata;charset=utf8', 'devphpde_sqluser', 's');
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

$insert = "INSERT INTO ".$table." (Username, Password, Email, Creationdate) VALUES (:name, :pass, :mail, :date)";

$stmt = $con->prepare($insert);

$stmt ->bindParam(':name', $name);
$stmt ->bindParam(':pass', $pass);
$stmt ->bindParam(':mail', $mail);

$stmt ->bindParam(':date', $today);

$stmt->execute();
PDO prepared statement -connect -prepare -bindparam -execute done.
 
PDO insert bindParam :
122014-12-17 22:25:22PHP
Edit this SnippetDelete this Snippet+1 upvote
$insertSQL = 'INSERT INTO ds_session (session_id, user_agent, session_expire, date_created, session_data)
VALUES (:SESSION_ID, :USER_AGENT, :SESSION_EXPIRE, :DATE_CREATED, :SESSION_DATA)';

$insertStmt = $this->pdo->prepare($insertSQL);
$insertStmt->bindParam(':SESSION_ID', $id);

...
$insertResult = $insertStmt->execute();
PDO insert with bindParam, prepare and select.
 
How to access $_POST in PHP
112014-12-16 22:04:19PHP
Edit this SnippetDelete this Snippet+1 upvote
if (filter_input(INPUT_POST, 'num') && filter_input(INPUT_POST, 'desc'))
 
Play audio
102014-11-27 22:25:50HTML
Edit this SnippetDelete this Snippet+1 upvote
<audio controls autoplay>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
 
for-schleife
92014-05-03 22:19:41PHP
Edit this SnippetDelete this Snippet+1 upvote
for ($i = 1; $i <= 5; $i++)
{
echo($i);
};
for-schleife, zählt von 1 bis 5
 
Hallo ein kleiner test
82014-05-03 15:20:03MySQL
Edit this SnippetDelete this Snippet+1 upvote
Hier ist ein testschnipsel.
 
MySQL Insert
72014-05-02 22:00:36PHP
Edit this SnippetDelete this Snippet+1 upvote
$query = "INSERT INTO ".$table." ( date ) VALUES ('".$today."');";

$result = mysql_query($query) or die ('Error connecting to mysql, query was: <BR><BR>'.$query. '<BR><BR> Error report: <BR><BR>'.mysql_error());
 
MySQL SELECT
62014-05-02 21:58:12PHP
Edit this SnippetDelete this Snippet+1 upvote
$query = "SELECT * FROM ".$table." ORDER BY count DESC";
 
MySQL connect
52014-05-02 21:25:32PHP
Edit this SnippetDelete this Snippet+1 upvote
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';

$dbname = '';

$link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("Error " . mysqli_error($link));

mysql_set_charset('utf8');

MySQL connect. $vars ausfüllen und go
 
$file exist?
42014-05-02 20:19:31PHP
Edit this SnippetDelete this Snippet+1 upvote
$file = $thumburl;
$file_headers = @get_headers($file);

if($file_headers[0] == 'HTTP/1.1 404 Not Found')
{
$exists = false;
}
else
{
$exists = true;
};
Prüft ob $file existiert.
 
Strings escapen (MySQL/HTML)
32014-05-02 19:39:56MySQL
Edit this SnippetDelete this Snippet+1 upvote
htmlspecialchars($string);
mysql_real_escape_string($string);
Strings für MySQL/HTML escapen. Beim schreiben für MySQL, beim Lesen für HTML.
 
Formular
22014-05-01 21:11:01HTML
Edit this SnippetDelete this Snippet+1 upvote
<form action="<?php echo($myuri); ?>" method="post" class="sampleform" >
<!-- accept-charset="UTF-8" -->
Formular
 
Today
12014-05-01 00:00:00MySQL
Edit this SnippetDelete this Snippet+1 upvote
$today = date("Y-m-d H:i:s");
MySQL-formatiertes Datum.