PD Insert not working no errors

This is very frustrating, it wont Insert and Im getting no error feedback.

$sql = "INSERT INTO Intranet (Contract_Number, Contract_Status, Company_Name, Invoice_Street, Invoice_City, Invoice_State, Invoice_Country, Invoice_Postcode, Invoice_Tax_Code, Invoice_Telephone, Invoice_Fax, Invoice_Contact_Name, Invoice_Email, Annual_Contract_Value, Invoicing_Profile, Invoice_Paid_By, Currency_of_Contract, Contract_Start, Contract_End, Renewal_Date, Contract_Length, Quote_Number, Site_Name, Street, City, Country, State, Postcode, Type_of_Establishment, No_of_Rooms, Group_Name, Invoice_Value, Invoice_Frequency, Payment_Contact, Payment_Contact_Tel, Invoice_Currency, Seasonal_or_Full, Month_Opens, Month_Closes, Brandcheck_Frequency, StandardsCheck_Frequency, Roomcheck_Frequency, Foodcheck_Frequency, Crisischeck_Frequency, Poolcheck_Frequency, Firecheck_Frequency, Aquacheck_Frequency, Spacheck_Frequency, Safetycheck_Frequency, Accesscheck_Frequency, Ecocheck_Frequency, Supplycheck_Frequency, Dinecheck_Frequency, Tourcheck_Frequency, Securitycheck_Frequency, Restaurantcheck_Frequency, Training_Days, Labcheck_Aqua_Frequency, Labcheck_Food_Frequency, Labcheck_Pool_Frequency, Labcheck_Room_Frequency, Legionella_Test_Frequency, No_of_Modules, Additional_Sampling, Principle_Contact, Principle_Telephone, Preferred_Language,Principle_Contact_Job_Title, Principle_Contact_Email, contract_File, date_Created) VALUES (:cNumberb, :cStatusb, :compNameb, :streetName1b, :cityName1b, :statePb, :countryName1b, :pCode1b, :vat1b, :tel1b, :fax1b, :contactNameb, :email1b, :cValueb, :iProfileb, :invPaidBy1b, :Invoice1b, :cStart1b, :cEnd1b, :rDate1b, :cLengthb, :qNumb, :pNameb, :street2b, :city2b, :country2b, :stateP2b, :pCode2b, :tEstablishmentb, :nRoomsb, :gNameb, :invValb, :iProfile1b, :paymentContactb, :cTel2b, :cInvoice2b, :seasonalFull1b, :mOpen1b, :mClosed1b, :BrandCheckNameb, :StandardsCheckNameb, :RoomCheckNameb, :FoodCheckNameb, :CrisisCheckNameb, :PoolCheckNameb, :FireCheckNameb, :AquaCheckNameb, :SpaCheckNameb, :SafetyCheckNameb, :AccessCheckNameb, :EcoCheckNameb, :SupplyCheckNameb, :DineCheckNameb, :TourCheckNameb, :SecurityCheckNameb, :RestaurantCheckNameb, :TrainingNameb, :LCAquaNameb, :LCFoodNameb, :LCPoolNameb, :LCRoomNameb, :LegionellaNameb, :cnt, :addsamplingb, :pContactb, :cTel3b, :preflanguageb, :jTitleb, :email2b, :contractFile, :nowC)";
$queryInsert=$conn->prepare($sql);
$queryInsert->bindParam(':cNumberb',$cNumberb);
$queryInsert->bindParam(':cStatusb',$cStatusb);
$queryInsert->bindParam(':compNameb',$compNameb);
$queryInsert->bindParam(':streetName1b',$streetName1b);
$queryInsert->bindParam(':cityName1b',$cityName1b);
$queryInsert->bindParam(':statePb',$statePb);
$queryInsert->bindParam(':countryName1b',$countryName1b);
$queryInsert->bindParam(':pCode1b',$pCode1b);
$queryInsert->bindParam(':vat1b',$vat1b);
$queryInsert->bindParam(':tel1b',$tel1b);
$queryInsert->bindParam(':fax1b',$fax1b);
$queryInsert->bindParam(':contactNameb',$contactNameb);
$queryInsert->bindParam(':email1b',$email1b);
$queryInsert->bindParam(':cValueb',$cValueb);
$queryInsert->bindParam(':iProfileb',$iProfileb);
$queryInsert->bindParam(':invPaidBy1b',$invPaidBy1b);
$queryInsert->bindParam(':Invoice1b',$Invoice1b);
$queryInsert->bindParam(':cStart1b',$cStart1b);
$queryInsert->bindParam(':cEnd1b',$cEnd1b);
$queryInsert->bindParam(':rDate1b',$rDate1b);
$queryInsert->bindParam(':cLengthb',$cLengthb);
$queryInsert->bindParam(':qNumb',$qNumb);
$queryInsert->bindParam(':pNameb',$pNameb);
$queryInsert->bindParam(':street2b',$street2b);
$queryInsert->bindParam(':city2b',$city2b);
$queryInsert->bindParam(':country2b',$country2b);
$queryInsert->bindParam(':stateP2b',$stateP2b);
$queryInsert->bindParam(':pCode2b',$pCode2b);
$queryInsert->bindParam(':tEstablishmentb',$tEstablishmentb);
$queryInsert->bindParam(':nRoomsb',$nRoomsb);
$queryInsert->bindParam(':gNameb',$gNameb);
$queryInsert->bindParam(':invValb',$invValb);
$queryInsert->bindParam(':iProfile1b',$iProfile1b);
$queryInsert->bindParam(':paymentContactb',$paymentContactb);
$queryInsert->bindParam(':cTel2b',$cTel2b);
$queryInsert->bindParam(':cInvoice2b',$cInvoice2b);
$queryInsert->bindParam(':seasonalFull1b',$seasonalFull1b);
$queryInsert->bindParam(':mOpen1b',$mOpen1b);
$queryInsert->bindParam(':mClosed1b',$mClosed1b);
$queryInsert->bindParam(':BrandCheckNameb',$BrandCheckNameb);
$queryInsert->bindParam(':StandardsCheckNameb',$StandardsCheckNameb);
$queryInsert->bindParam(':RoomCheckNameb',$RoomCheckNameb);
$queryInsert->bindParam(':FoodCheckNameb',$FoodCheckNameb);
$queryInsert->bindParam(':CrisisCheckNameb',$CrisisCheckNameb);
$queryInsert->bindParam(':PoolCheckNameb',$PoolCheckNameb);
$queryInsert->bindParam(':FireCheckNameb',$FireCheckNameb);
$queryInsert->bindParam(':AquaCheckNameb',$AquaCheckNameb);
$queryInsert->bindParam(':SpaCheckNameb',$SpaCheckNameb);
$queryInsert->bindParam(':SafetyCheckNameb',$SafetyCheckNameb);
$queryInsert->bindParam(':AccessCheckNameb',$AccessCheckNameb);
$queryInsert->bindParam(':EcoCheckNameb',$EcoCheckNameb);
$queryInsert->bindParam(':SupplyCheckNameb',$SupplyCheckNameb);
$queryInsert->bindParam(':DineCheckNameb',$DineCheckNameb);
$queryInsert->bindParam(':TourCheckNameb',$TourCheckNameb);
$queryInsert->bindParam(':SecurityCheckNameb',$SecurityCheckNameb);
$queryInsert->bindParam(':RestaurantCheckNameb',$RestaurantCheckNameb);
$queryInsert->bindParam(':TrainingNameb',$TrainingNameb);
$queryInsert->bindParam(':LCAquaNameb',$LCAquaNameb);
$queryInsert->bindParam(':LCFoodNameb',$LCFoodNameb);
$queryInsert->bindParam(':LCPoolNameb',$LCPoolNameb);
$queryInsert->bindParam(':LCRoomNameb',$LCRoomNameb);
$queryInsert->bindParam(':LegionellaNameb',$LegionellaNameb);
$queryInsert->bindParam(':cnt',$cnt);
$queryInsert->bindParam(':addsamplingb',$addsamplingb);
$queryInsert->bindParam(':pContactb',$pContactb);
$queryInsert->bindParam(':cTel3b',$cTel3b);
$queryInsert->bindParam(':preflanguageb',$preflanguageb);
$queryInsert->bindParam(':jTitleb',$jTitleb);
$queryInsert->bindParam(':email2b',$email2b);
$queryInsert->bindParam(':contractFile',$contractFile);
$queryInsert->bindParam(':nowC',$nowC);
$queryInsert->execute();

print_r($conn->errorInfo());

I added the print_r above and it came back with

Array
(
    [0] => 00000
    [1] => 
    [2] => 
)

shouldn’t that rather be $queryInsert->errorInfo() ?

Note: better add

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

before the statement, so you will immediately be notified about problems.

1 Like

Ah, brilliant, thats showed me an error, so hopefully can resolve this

Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[23000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot insert the value NULL into column ‘Currency_of_Contract’, table ‘Dev_CSF_Intranet.dbo.Intranet’; column does not allow nulls. INSERT fails.’ in upload_contract.php:948 Stack trace: #0 upload_contract.php(948): PDOStatement->execute() #1 {main} thrown in

well, you can’t insert NULL into a NOT NULL column …

Thanks again Dormilich, learning quickly today lol

I’ve highlighted the relevant part of the error message, so you know where to look next time.

1 Like

It’s probably in the form itself then, as I have selected a value form the drop down so it cant be passing it to the insert statement

mmm, strange, the form is fine, its posting a value, I have just echo’d it out but its not registering in the db. Needs some further looking into by the looks, but thank you

OK I resolved it, human error ( I want go into it lol)

At least now I can see the errors by adding that line of code.

But have now got another and its not as detailed where the error is -

Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error converting data type nvarchar to numeric.’ in

Don’t know much about SQL Server, you would have to check the documentation for that error.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.