I’m tearing my hair out! I’ll be damned if I can figure out what’s wrong with this INSERT statement. I pulled all my error-checking out (nulls, dupes and stuff) and simplified this snippet as much as I can.
-
I know I’m connected to the DB.
-
I know I have the variables.
-
I see “Bingo” so I know I went by the INSERT.
-
I never see “success” OR “error.”
-
Table definition included as image.
<?php // Declare Connection Variables $servername = "xxxxxx"; $email = "xxxxxxxx"; $passwrd = "xxxxxxxxxx"; $dbname = "xxxxxxxx"; // Create connection $dbconnect = mysqli_connect($servername, $email, $passwrd, $dbname); // Check connection if (!$dbconnect) { die("Connection failed: " . mysqli_connect_error()); mysqli_close($dbconnect); } echo "Connected successfully"; //if submit is not blanked i.e. it is clicked. echo $_REQUEST['email']; echo $_REQUEST['passwrd']; echo $_REQUEST['submit']; $email=$_REQUEST['email']; $passwrd=$_REQUEST['passwrd']; $politics=0; $gender=0; $race=0; $orientation=0; $income=0; $region=0; echo Variables; echo $email; echo $passwrd; $sql = "INSERT INTO person (politics, gender, race, orientation, income, region, email,passwrd) VALUES ($politics, $gender, $race, $orientation, $income, $region, $email, $passwrd)"; echo Bingo; if ($dbconnect->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $dbconnect->error; } mysqli_close($dbconnect); ?>
Thanks for responding. This is embarrassing!
- Admin Edited: Added Code Tags