php - INSERT INTO called once but runs twice (not in a loop) -
I have a query that appears every time, it is run twice, which is not intended to be done before and after The logging in the file is added and the file is cleaned before running the script.
I do not think I have to post another code because I believe my logging proves that this query is only called once.
code:
file_put_contents ($ _SERVER ['DOCUMENT_ROOT']. '/ PDOErrors.txt', "\ n \ n 1 query immediately before the ban." Date ('r'). "(1)", FILE_APPEND); $ Sth = $ mdbh- & gt; Query ("INSERT INTO banned_IP SET ip_add = '$ ip', proxy_ip = '$ proxy_ip'"); $ Sth- & gt; Executed (); File_put_contents ($ _SERVER ['DOCUMENT_ROOT']. '/ PDOErrors.txt', "\ n \ n User banned using query 1." .date ('r'). "(2)", FILE_APPEND) ; Return 999; Note that immediately after its running immediately there is a return and even if it is called twice, then my PDOErrors The .txt file will show diagnostic data for each run, which does not. PDOErrors.txt runs the first diagnostic data, but the second never runs! Here is a copy of PDOErrors.txt
Precisely before the restriction query 1. Thu, 21 Mar 2013 13:38:56 +0800 (1) Exception 'PDOException 'With message' SQLSTATE [23000]: Conflict of Integrity Handicap: 1062 Duplicate Entry '127.0.0.1' for 'ip_add' '/ home / speaker / documents / websites / our_websites / bookkeeper / books / bookkeeper / public / include / Classes / loginAttempt Class.php: 137 Stack Trace: # 0 Home / Speaker / Document / Websites / Our_websites / Bookkeeper / Books. Bookkeeper.f / Public / Inclusion / Category / Long: V.PP (137): PDOSTATment - & gt; Execute () # 1 /home/peter/Documents/websites/Our_websites/bookkeeper/books.bookkeeper.ph/public/includes/classes/login.class. Php (980): Login-> Record Login Att (Array) # 2 / Home / Spear / Documents / Website / Our_Websites / Bookkeeper / BooksbookPier.F / Public / AJAX / Login. User.fip.25): login-gt; DoLogin (Array) # 3 {main} Let me tell you that before each run, I will completely clear the banned_IP database table. I am also logging all the questions because it is a development environment and the log of the query can be seen below:
708 queries restricted in the INSERT iIP SET ip_add = '127.0.0.1', proxy_ip = '708 question INSTEED, restricted IP SET ip_add =' 127.0.0.1 ', Proxy_IP =' 708 Leave I think only this question That would include two sets of diagnostic data in PDOERs .txt if not query on an empty database table Sector has generated an error message on the very first run. What could be the reason for this?
PDO-> The query will execute a query and PDOStatement will return the object, now you are returning PDOStment again which causes this error.
Use PDO-> PDO-> which gives the PDOSTMent object and then executes the statement or PDO-> Use Query and do not execute PDOATatament
Comments
Post a Comment