I'm trying to pass a variable from javascript to php using this simple code and then I want to put it into my database:
<?php
mysql_select_db($database_Connessione_server,$Connessione_server); //connection to db
$ind = 1;
<script>
var i = 10;
<?php
$ind = $GET['i'];
mysql_query("INSERT INTO table1 VALUES (".$ind.")");
?> </script>
but I keep getting the same error: Uncaught SyntaxError: Unexpected token < The connection to the db works, but the GET method doesn't get the value 'i'. Getting the type of the variable 'ind' I get undefined index i. Can someone help me to solve the problem? Is there another method to insert variables into database using javascript?
--EDIT--- What I want is to understand why my code doesn't work and what that error means in my case. I already read the answers to the other questions but couldn't find a solution.