Search the Community
Showing results for tags 'mysqli php'.
-
Ok i have 2 issues i will start with the harder one first as it is more past my experties and i have spent time troubleshooting and cant get it solved i have 1 player name email address and 2 random numbers(ballots) that im trying to enter into my db after lengthy playing with the code i have 2 sql insert statements which will only grab the last one into the db Method 1 Steps i tried and results created 2nd table for the 2nd insert RESULT Only inserts to 2nd table echo only shows 2nd insert Method 2 name the sql insert to sql and sql1 same table RESULT gives me Warning: mysqli_multi_query() expects exactly 2 parameters, 3 given in but echos correctly Method 3 Name the sql insert to sql and sql1 different table Result gives me same warning and echos correctly Ideally i would like it to go into 2 rows in same table but am ok with having 2 separate table here is the code // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "INSERT INTO ballot (username, useremail, randomnumber) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["output"]."')"; $sql1 = "INSERT INTO bonus (username, useremail, randomnumber) VALUES ('".$_POST["username3"]."','".$_POST["email"]."','".$_POST["randomnumber3"]."')"; echo $sql ; if (mysqli_multi_query($conn, $sql, $sql1)) ; { echo "New records created successfully"; } mysqli_close($conn); ?>