I have the While working, This is not really true. If you can not decide, you should help in choosing. However, you should know that, PDO is capable of working with various types of RDBMS, whereas MySQLi has been created for a particular purpose, if you decide to go with the PDO, then it is recommended that you follow. < P> For your special case, your code should look like this: - Note: - You get a specific $$ _POST or $ _GET; As far as $ _REQUEST can come from and you should always know where your input is coming from. User input should always be valid, your method will leave you widely for SQL injection, so This is traditional, while talking about SQL injection to tell the story of the Little Bobby Tables, here it is: - To continue your code: - I do not stress enough It is possible that the code given above is unsafe and should never be used on the live. Learn to use the Mysql_ * functions do not disturb, you are wasting your time. PDO is not difficult to learn and In Tv, you know it's quite simple after hanging. You will find the tutorial up well using PDO successfully on the way. urlOne field in my database. I would like it only HTML e if it has URL Value is in the form. Here is my code:
$ id = $ _REQUEST ['id']; $ Query = "SELECT * sites from WHERE id = $ id LIMIT 1"; $ Result = mysql_query ($ query); $ Url = $ line ['urlOne']; While ($ line = mysql_fetch_assoc ($ result)) {resonant "& lt; section class = 'support' & gt;"; Echo per $; Echo "& lt; / section & gt;"; $ Result = mysql_query ("SELECT * FROM Sites WHERE $ id LIMIT 1"); If (empty! ($ Line ['urlOne'])) {echo "<470 =" cta "> }}
mysql _ * Functions are no longer created and the community has started. Instead, you should learn about it and use it. Or
$ dsn = 'mysql: dbname = dbname; host = 127.0.0.1'; $ User = 'dbuser'; $ Try password = 'dbpass'; {$ Db = New PDO ($ DSN, $ user, $ password); $ Db- & gt; Set Attribute (PDO :: ATTRRA) Rmodii, PDO :: Iarmmmdimaksiseepitian); $ Db- & gt; Set attribute (PDO :: ATTR_EMULATE_PREPARES, incorrect); } Hold (PDOException $ e) {echo 'connection failed:'. $ E & gt; GetMessage (); } $ Id = someMethodOfValidation ($ _ POST ['id']);
someMethodOfValidation () bits to fit your expected input You will need to type in your case it seems that you are expecting an integer value, so your verification
$ id = (int) $ _ POST ['id'];
$ Stmt = $ db- & gt; Ready ("SELECT * FROM Sites WHERE id =: id"); $ Stmt- & gt; Execute (array (': id' = & gt; $ id)); $ Rows = $ stmt-> Get All (PDO :: FETCH_ASSOC); Foreign currency ($ lines as $ line) {If (empty! ($ Line ['urlone']) {resonant "
Comments
Post a Comment