Jump to content

Error Reporting


TapeGun007

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.