Jump to content

Using PDO instead of mysql_ ?


popcop

Recommended Posts

im currently using this code...

 

// connect to and select the database
@mysql_connect($host,$user,$password) or die("&success=no&");
@mysql_select_db($dbname) or die("&success=no&");
// query the database and return an array of data
$result = @mysql_query("SELECT * FROM $tablename WHERE rand = $rand") or die("&success=no&");

 

i keep getting told not to use it and to now use PDO instead, can someone please show me exactly how i change the above code to PDO

Link to comment
https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/
Share on other sites

Unless you NEED to use the features of PDO (and alter your code for the mysql features that PDO doesn't have any equivalent function for), you should switch from mysql to mysqli.

 

Switching from mysql to mysqli can be accomplish by changing function names and swapping or adding function parameters (mysqli switched parameter usage and made them non-optional.)

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.