Hallo zusammen,
ich versuche einen link zähler im beitrag zu erstellen und habe dazu folgenden
code erstellt:
PHP
{source}<?php include("/Bibliothek/counter-php/counter.php"); ?>{/source} <tr> <td width="60px" height="40px"><img src="/images/Logos/logo.png" /></td>{source} <?php echo "<td width=\"400px\"><a href=\"counter.php?url=/Bibliothek/counter-php/test.txt\">Textlink</a></td>"; ?>{/source} </tr>
php file:
PHP
<?php
$host = "localhost";
$user = "test";
$pass = "test";
$datab = "testdb";
$table = "testtbl";
$url = addslashes($_GET['url']);
$db = @mysqli_connect($host, $user, $pass);
if ($db) {
if (@mysqli_select_db($datab, $db)){
$query = "UPDATE $table SET count = count + 1 WHERE url = '$url'";
$result1 = @mysqli_query($query);
if ($result1) {
echo "Counter +1";
}
}
else{
if (mysqli_affected_rows() == 0){
$sql_insert = "INSERT INTO $table (url, count) VALUES ('$url', '1'))";
$result2 = @mysqli_query($sql_insert);
if ($result2) {
echo "New record created successfully";
}
}
}
}
mysqli_close($db);
?>
Alles anzeigen
DB Mysql phpmyadmin:
id:int(auto)
url:char
count:int
kann jemand helfen?
Gruß Franz