TapeGun007 Posted August 6, 2015 Share Posted August 6, 2015 I'm trying to figure out my bug here, and I what I really want to know is how to debug my own code which would result in less posting here. Also it would be nice to contribute and help others as I learn from my mistakes. I have this code: mysqli_report(MYSQLI_REPORT_ALL); This is near the top of my code after all the include files. Then below after a form I have this code: $sql = "INSERT INTO Prospects (ProspectCode, ProspectBusinessName, ProspectName, ProspectAddress, ProspectAddress2, ProspectCity, ProspectState, ProspectZip, ProspectCounty, ProspectCountry) VALUES (?,?,?,?,?,?,?,?,?,?)"; // Check $sql to ensure it's correct echo "<p>$sql</p>"; /* Prepared statement, stage 1: prepare */ if (!($stmt = $con->prepare($sql))) { echo "Prepare failed: (" . $con->errno . ") " . $con->error; } // Bind parameters, stage 2. Types: s = string, i = integer, d = double, b = blob if (!$stmt->bind_param('ssssssssss', $ReferralCode, $Business, $Contact, $Address, $Address2, $City, $State, $Zip, $County, $Country)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } // Execute. stage 3 if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } I'm trying to error check, so I could debug it myself, but there is no error. Weirdly enough, it worked fine up until I added County and Country. *sigh* It's probably some very simple syntax error, but how come it doesn't produce an error so I can troubleshoot the problem? Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/ Share on other sites More sharing options...
scootstah Posted August 6, 2015 Share Posted August 6, 2015 Is the "Execute failed" part showing? Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/#findComment-1518169 Share on other sites More sharing options...
TapeGun007 Posted August 6, 2015 Author Share Posted August 6, 2015 No. When I submit the form, the top header menu appears and nothing below. It's just a blank page. Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/#findComment-1518172 Share on other sites More sharing options...
TapeGun007 Posted August 6, 2015 Author Share Posted August 6, 2015 Ok, I figured out WHY I'm getting an error. I didn't add the table ProspectCounty as of yet. But again, my question more or less is related to why this doesn't generate an error so that I could troubleshoot from there. Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/#findComment-1518173 Share on other sites More sharing options...
mac_gyver Posted August 6, 2015 Share Posted August 6, 2015 with the mysqli_report set, all that will do is reporting errors/throw exceptions. to display or handle the reported errors, you need to either put a try/catch block around your code and handle the thrown error yourself, or you need to have php's error_reporting set to E_ALL and display_errors set to ON so that the reported mysqli errors or the uncaught exception will be reported and displayed. Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/#findComment-1518176 Share on other sites More sharing options...
TapeGun007 Posted August 6, 2015 Author Share Posted August 6, 2015 Thanks mac_gyver. I did my homework on what you said as I wasn't sure where to set this. I used this to do it for now and will set it back later. ini_set("display_errors", 1);ini_set("track_errors", 1);ini_set("html_errors", 1);error_reporting(E_ALL);[/cdoe] That gave me the error I was looking for on another page and was able to quickly resolve the issue. Link to comment https://forums.phpfreaks.com/topic/297668-error-reporting/#findComment-1518177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.