Guest User

Untitled

a guest
Apr 14th, 2016
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. /* SQL */
  2.  
  3. $sql = "UPDATE Exchange SET poundRate= $_pounds, dollarRate= $_dollars, euroRate= $_euros";
  4. $result = mysql_query($sql) or die(mysql_error());
  5.  
  6. /* some other general usage */
  7.  
  8. $num_rows = mysql_num_rows($result);
  9.  
  10. while($row = mysql_fetch_assoc($result)) {
  11.    echo $row['field1'].' '.$row['field2']; //etc...
  12. }
  13. ========== IMPORTANT ========================= BUT, BUT Y U STILL USE THIS OLD GRUMPY THING??===================
  14. PLEASE DON'T, FOLLOW UP WITH YOUR TOOLS, LEARN PDO and PREPARED STATEMENTS:
  15. like... now!
  16.  
  17. /* Connect with PDO */
  18.  
  19. $connection = new PDO('mysql:host=localhost;dbname=my_db;charset=UTF-8','username', 'password');
  20.  
  21. $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  22. $connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  23. // connection is all setup
Add Comment
Please, Sign In to add comment