0

I've database with a score. It starts of as 0 and when I press a button it should change to 1 on top of that number. If it was 7 it would then be 8. `

This is the file which when you click the link it would take you to

<?php
$con=mysqli_connect("localhost","root","root","score");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
session_start();
$id=$_SESSION['id'];


// Perform queries 
mysql_query($con,"
    UPDATE all_scores
    SET score1 = score1 + 1
    WHERE id = '".$id."'
")or die(mysql_error());

mysqli_close($con);
?>

This code should update the number from 0 to 1 or 1 to 2 depending on what number is on the database. My database name is scores. The table is all_scores the row numbers are listed as id and what I need updated is score1. The row that it updates depends on the id classified in the session as you can see. Please help. It doesn't update into my database.

PRJ
  • 15
  • 7

0 Answers0