Jump to content

sixbeforewdawn

Members
  • Posts

    2
  • Joined

  • Last visited

sixbeforewdawn's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thank you so much for the help it's working great. And gives me a lot of help for future php scipts
  2. Hi Sorry if this is a really simple question, I have looked round but can't a solution to my problem. If anyone can help or point me in the right direction I have a html form which runs the below PHP script <?php$con=mysqli_connect("localhost","username","password","mydatabase");// Check connectionif (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error();}$sql="INSERT INTO mytable (name, score,score2)VALUES('$_POST[name]','$_POST[score]','$_POST[score2]')";if (!mysqli_query($con,$sql)){ die('Error: ' . mysqli_error($con));}echo "Your Score has been added";mysqli_close($con); ?> Which inserts the data in to MySQL without any problems But I'd like the code to add 'score' and 'score1' together and insert this in to MySQL. I have tried adding $total = score + score1; $sql="INSERT INTO mytable (name, score, score2, total)VALUES('$_POST[name]','$_POST[score]','$_POST[score2]','$_POST[$total]')"; But it just inserts a 0 Cheers
×
×
  • Create New...