PHP Insert code not working PDO


I did remove the try/catch logic and it worked. The $result was supposed to be $result = "<p style='color:green;'>Registration Successful</p>
NOT <p style='color:green;'>An error occured: </p>
It should not give error after successfully signup…



I am doing that and trying my level best to apply it…Thanks!!


You can also download my PDO Bumpstart Database. It will help you with a lot of the basics.


Thanks alot!!!


Well, you shouldn’t rely on try-catch blocks. But all you just really need to do is be careful where you place your second curly brace. That should be a fairly decent hint.

PDO does has its ups and downs. Choosing between the 2 database APIs is pretty much based on preference. There are certain things that PDO can’t do that mysqli_* can do. For example, executing an SQL file. PDO has an alternative, but it doesn’t seem that safe IMO. For PDO's you just use $stmt->exec($file), but it seems a bit iffy since you are pretty much running the exec() function. I don’t use the exec() function much, but I am basing it off of the eval() functions. Maybe I’m wrong and if I am, correct me on this.


Thanks so much @spaceshiptrooper I will surely do that…


Well, if you don’t have that line that exits the script when it hits the catch block, execution will continue and when the form is re-drawn, your $result variable will be displayed, and then you’ll see the error message. Or just echo($result) before you exit, for now.


Thanks @droopsnoot for that info…I appreciate!


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