Mercurial > hg > ywww
view php/read/updateLink.php @ 23:d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
author | Charlie Root |
---|---|
date | Sun, 30 Dec 2018 07:00:09 -0500 |
parents | 84a412b8122c |
children | f024f2f08994 |
line wrap: on
line source
<?PHP $linkID = strval($_GET['linkID']); echo $linkID; $change = strval($_GET['change']); echo $change; $dir = strval($_GET['dir']); echo $dir; $userID=""; $userID = strval($_GET['userID']); echo $userID; include "../../../private/db.php"; $pos = 0; $neg = 0; if($change == "pos") { if($dir == "pos") { $state = 1; $pos = 1; } else { $state = 0; $pos = -1; } } else { if($dir == "pos") { $state = -1; $neg = 1; } else { $state = 0; $neg = -1; } } if($userID == "") { $updateQuery = 'CALL b_changeLink('. $linkID . ',' . $pos .',0,' . $neg .',0)'; echo $updateQuery; $dataFinal = mysqli_query($link, $updateQuery); } else { $check = 'CALL b_getStateID('. $userID .','. $linkID .')'; //select StateID from thumbstate where UserID = ' . $userID . ' and linkID = ' . $linkID; echo $check; $result = mysqli_query($link, $check) or exit( mysqli_error( $link )); $count=mysqli_num_rows($result); if($count==1){ $rows=mysqli_fetch_array($result, MYSQLI_ASSOC); $stateID=$rows['StateID']; $stateQuery = "CALL b_updateThumbState($stateID,$state)"; } else { $stateQuery = "CALL b_insertThumbState($userID,$linkID,$state)"; } echo $stateQuery; mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop include "../../../private/db.php"; $stateFinal = mysqli_query($link, $stateQuery) or exit( mysqli_error( $link )); } //if email not zero, select userid from user where email=email //insert into thumbstate null,userid,linkid,state (1,0,-1) mysqli_close($link); ?>