My script:
<?php ob_start(); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-type: text/html; charset=utf-8'); include "tilslut.php"; $userid = $_GET["userid"]; $s = mysql_query("SELECT points, lastpoint FROM member_profile WHERE user_id = '".$userid."'"); $n = mysql_fetch_array($s); $tid = time(); mysql_query("UPDATE member_profile set points = points+1, lastpoint=$tid WHERE lastpoint<=$tid-60 AND user_id = '".$userid."'"); $e = mysql_query("SELECT points FROM member_profile WHERE user_id = '".$userid."'"); $f = mysql_fetch_array($e); if (mysql_affected_rows() == 1) { $s = mysql_query("SELECT points FROM member_profile WHERE user_id = '".$userid."'"); $n = mysql_fetch_array($s); ?> Inserted! <? }else{ echo "Already got"; } ob_flush(); ?>
I have this to give points. The update request works and gives only a point if lastpoint <= time () is 60, but it still says “Insert”, even if it does not insert. I tried using the rows affected by mysql to check whether it was affected or not, but this does not seem to work.
you need to call mysql_affected_rows right after the update before making another choice. mysql_affected_rows will only work with the last query executed on the connection.
Your location is:
update
select
mysql_affected_rows
, mysql_affected_rows update, : mysql_affected_rows - 't select , , .
: SQL Injection, : SQL- ( $_GET["userid"]) , , , .
$_GET["userid"]
: $e, $f, $n, $s,... //: - (
$e
$f
$n
$s
$e = mysql_query("SELECT points FROM member_profile WHERE user_id = '".$userid."'");
, .
Source: https://habr.com/ru/post/1732905/More articles:java object casting as PrintWriter - javaASP.NET User / Role Editor - c #Scala Implementing the last haskell method - scalaCan the terms "variable" and "field" be used interchangeably in java? - javaScript to generate default values for non-columns that do not have default values specified in SQL Server - mysqlUsed FileStream - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1732907/get-divs-to-behave-like-a-table&usg=ALkJrhgVs7O3HecgfzlzpLvlxo43Qz3cogDistributing sharepoint default.master? - sharepointWhy does the Moose role application with method modifiers not work in my code? - perlFor general cases, when one of them will work, which is better to use, a hash map or a hash table? - javaAll Articles