Created
July 17, 2015 22:16
-
-
Save alteredorange/0fad2c9a67c3a1c0d185 to your computer and use it in GitHub Desktop.
PDO Stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** begin the session ***/ | |
session_start(); | |
// Connection to database | |
$connection=mysqli_connect("localhost","root","Iamdone2010","vrcrush"); | |
// Check connection | |
if (mysqli_connect_errno()) | |
{ | |
echo 'NOT_OK'; | |
//echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
//Check if Voted Already | |
$query="INSERT INTO voted (user_id,news_id) VALUES (?,?)"; | |
$stmt=$connection->query($query); | |
$stmt->bind("ii",$_SESSION['ID'],$_POST['id1']); | |
$stmt->execute(); | |
$error=$mysqli_stmt->errno($stmt); | |
if(!$error) { | |
mysqli_query($connection,"UPDATE news SET votes=(votes + 1) WHERE ID='". $_POST['id1'] . "'"); | |
} | |
else { | |
//Do Nothing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment