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
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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.