Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 19:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Counter PHP - Problem

Discussion on Counter PHP - Problem within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
lnqlorlouz's Avatar
 
elite*gold: 0
Join Date: Jun 2013
Posts: 405
Received Thanks: 84
Lightbulb Counter PHP - Problem

Servus,

hab irgendeinen kleinen Fehler...
Ich möchte auf meiner Seite Shishaköpfe zählen. Und jedes mal wenn man auf den Button klickt, sollte es um 1 erhöht werden.
Hab schon viele Möglichkeiten probiert, aber es funktioniert einfach nicht!

Button:
PHP Code:
<form action="intern_insert_topf.php" method="POST" autocomplete="off">
<input type="submit" class="btn btn-lg btn-success" value="<?PHP echo $topf;?>">
</form>
Verarbeitung:
PHP Code:
$topf mysqli_real_escape_string($conn$_POST['topf']);
$topff 1;
$topfcount $topf $topff;

date_default_timezone_set('Europe/Berlin');
$timestamp time(); 

$sql "UPDATE login SET lastchangetopf='".$timestamp."', topf='".$topfcount."' WHERE id='".$_SESSION['user_id']."'"
oder
PHP Code:
$topf mysqli_real_escape_string($conn$_POST['topf']);
$topf++;

date_default_timezone_set('Europe/Berlin');
$timestamp time(); 

$sql "UPDATE login SET lastchangetopf='".$timestamp."', topf='".$topf."' WHERE id='".$_SESSION['user_id']."'"
Beide Varianten gehen nicht.

Wenn der Counter auf 0 ist, dann erhöht er komischerweise auf 1, aber von 1 nicht auf 2 und so weiter...
lnqlorlouz is offline  
Old 02/09/2015, 20:47   #2



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
ersetz mal

$topf++;

durch

$topf = intval($topf) + 1;

edit;
deinem input fehlt ein name="topf", wie auch immer, du solltest lieber devsome's methode benutzen
Shawak is offline  
Old 02/09/2015, 20:53   #3
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,840
Received Thanks: 4,672
Oder

Quote:
$sql = "UPDATE login
SET lastchangetopf = ' " . $timestamp . " ',
topf = topf +1
WHERE id = ' " . $_SESSION['user_id'] . " ' ";
Devsome is offline  
Old 02/09/2015, 22:31   #4
 
lnqlorlouz's Avatar
 
elite*gold: 0
Join Date: Jun 2013
Posts: 405
Received Thanks: 84
Quote:
Originally Posted by Shawak View Post
deinem input fehlt ein name="topf", wie auch immer, du solltest lieber devsome's methode benutzen
Danke! Ich Trottel...hab doch gewusst, meine Varianten müssten auch gehen. Hab das nämlich schon ein paar Mal gemacht und war jetzt aber wirklich verunsichert...
Ich merke mir aber mal eure Varianten. Könnten vielleicht für andere Dinge effizienter sein, wer weiß.
lnqlorlouz is offline  
Reply

Tags
amateur, counter, problem




All times are GMT +1. The time now is 19:03.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.