0

My program is supposed to insert a bunch of data into a customer table but after the program runs, nothing is added to the table. It isn't giving any errors either so I'm confused as to what I have wrong. I've inserted data into a table multiple times before and have never had this issue.

Code:

//fetch Service Form inputs
$fname = filter_input(INPUT_GET, 'fname');
$lname = filter_input(INPUT_GET, 'lname');
$name = $fname . " " . $lname; 
$city = filter_input(INPUT_GET, 'city');
$state = filter_input(INPUT_GET, 'state');
$zip = filter_input(INPUT_GET, 'zip');
$phone = filter_input(INPUT_GET, 'phone');
$email = filter_input(INPUT_GET, 'email');
$custNum = filter_input(INPUT_GET, 'custNum');
$vehNum = filter_input(INPUT_GET, 'vehNum');

//perform update
require_once('../db_connect.php');

//Insert values for Customer
$queryCustomer = 'INSERT INTO customer
                    (CUST_NUM, VEH_NUM, CUST_NAME, CUST_CITY, CUST_STATE, CUST_ZIP, CUST_PHONE, CUST_EMAIL)
                VALUES
                    (:custNum, :vehNum, :name, :city, :state, :zip, :phone, :email)';

$statement3 = $db1->prepare($queryCustomer);
$statement3->bindValue(':custNum', $custNum);
$statement3->bindValue(':vehNum', $vehNum);
$statement3->bindValue(':name', $name);
$statement3->bindValue(':city', $city);
$statement3->bindValue(':state', $state);
$statement3->bindValue(':zip', $zip);
$statement3->bindValue(':phone', $phone);
$statement3->bindValue(':email', $email);
$statement3->execute();
$statement3->closeCursor();

I've tested all the values being inserted and they are all being obtained without any issues.

This is the database table

Any help is appreciated. Let me know if I should include anything else.

nbk
  • 45,398
  • 8
  • 30
  • 47
Sam
  • 37
  • 5
  • 1
    Does this answer your question? [My PDO Statement doesn't work](https://stackoverflow.com/questions/32648371/my-pdo-statement-doesnt-work) – El_Vanja Mar 29 '20 at 01:00
  • 1
    insert's is normally done with POST – Lawrence Cherone Mar 29 '20 at 01:09
  • Is `CUST_NUM` an autoincremented column? I would hope so, but we cannot see any evidence of that because we are seeing the data rows and not the full schema. You are seeking debugging support, but have not provided enough vital details. – mickmackusa Mar 29 '20 at 02:00
  • @El_Vanja Thank you so much. I enabled errors and found that the value being entered for phone number is was too large and should have been varchar instead of int. Apologies for not listing that info to begin with. – Sam Mar 29 '20 at 18:37

0 Answers0