popcop Posted February 6, 2013 Share Posted February 6, 2013 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 More sharing options...
Jessica Posted February 6, 2013 Share Posted February 6, 2013 Did you read the manual? Link to comment https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/#findComment-1410427 Share on other sites More sharing options...
popcop Posted February 6, 2013 Author Share Posted February 6, 2013 This was code i did years ago and im re-using it for something im working on, im not really a PHP developer so im just looking for some advice Link to comment https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/#findComment-1410430 Share on other sites More sharing options...
Andy123 Posted February 6, 2013 Share Posted February 6, 2013 Everything you need to know is in the manual - particularly in the "PDO" and "PDOStatement" sections. Otherwise, a quick Google search should give you what you need. I quickly found this one and it looks good. I didn't read it, though. Link to comment https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/#findComment-1410431 Share on other sites More sharing options...
PFMaBiSmAd Posted February 6, 2013 Share Posted February 6, 2013 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 https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/#findComment-1410433 Share on other sites More sharing options...
popcop Posted February 6, 2013 Author Share Posted February 6, 2013 thanks for that, its going slightly over my head though... can anyone give me a quick explaination on howd id change that? Link to comment https://forums.phpfreaks.com/topic/274100-using-pdo-instead-of-mysql_/#findComment-1410435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.