www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Cant figure out why this isnt working.

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    2

    resolved [RESOLVED] Cant figure out why this isnt working.

    So, im new around here and not quite sure if this should go in the php or the sql seeing is how its a bit of both, but my questions pertains to why my perpare statment doesnt work. Onto the question. My first prepare statments for the select works as should. The result is returned properly. So if there is no entry in the table with the id_address that matches it correctly goes into the if statement and then the second prepare statement is exicuted properly and the data is entered into the table. the second time around when i know that the entry is in the table so it should skip the first if because there is data in the $result, and it is less than 5. it goes into the if statement and echos $update_attempt. the issue i cant seem to resolve is that the update prepare statment to update the entry in the table fails and I cant seem to figure out why.

    Code:
    $attack = true;
    if($stmt = $mysqli->prepare("SELECT `login_attempts`, `id` FROM attempts WHERE `id_address`=? LIMIT 1")){
    	$stmt->bind_param("s", $crypt_address); /* Bind parameters s - string, b - boolean, i - int, etc */
    	$stmt->execute(); /* Execute it */
    	$stmt->bind_result($result, $id); /* Bind results */
    	$stmt->fetch(); /* Fetch the value */
    	if(!$result){
    	        $attack = false;
    		$new_attempt = 1;
    		if($new_stmt = $mysqli->prepare("INSERT INTO `attempts`(`login_attempts`, `id_address`) VALUES(?, ?)")){
    		        $new_stmt->bind_param("is", $new_attempt, $crypt_address); /* Bind parameters s - string, b - boolean, i - int, etc */
    			if(!$new_stmt->execute()){ /* Execute it */
    				echo "FAIL";
    			}
    			$new_stmt->close(); /* Close statement */
    		}		
    	}
    	if($result <= 5){
    		$attack = false;
    		$update_attempt = $result + 1;
    		echo $update_attempt;
    		if($update_stmt = $mysqli->prepare("UPDATE `attempts` SET `login_attempts`=? WHERE `id_address`=?")){
    			$update_stmt->bind_param("is", $update_attempt, $crypt_address); /* Bind parameters s - string, b - boolean, i - int, etc */
    			if(!$update_stmt->execute()){ /* Execute it */
    				echo "FAIL";
    			}
    			$update_stmt->close(); /* Close statement */
    		}
    	}
    	$stmt->close(); /* Close statement */
    }
    return $attack;

  2. #2
    Join Date
    Apr 2013
    Posts
    2
    i figured it out

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles