PHP Insert code not working PDO


#22

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…

login


#23

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


#24

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

https://github.com/benanamen/pdo_bumpstart_ver1.6


#25

Thanks alot!!!


#26

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.


#27

Thanks so much @spaceshiptrooper I will surely do that…


#28

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.


#29

Thanks @droopsnoot for that info…I appreciate!


#30

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