hey guys, I'm trying to switch my mysql connections over to PDO but I'm having a hard time. I've read a section on it in the php book I'm reading, I watched the phpacademy,org tutorial on it, I've read the section on it here at w3schools and I can't get it working. I've also posted it on 2 other forums and no one has yet to figure out where the problem is and it's eaten up 2 days of my time as well. If I can't get it figured out today I'm seriously thinking of going back to using the old mysql functions because they worked right the first time and have never given me an ounce of trouble. It's just very frustrating that my registration/login system was working perfect and then I upgrade and nothing works and no one can figure it out. . . It says the error is on line 142, which is the fetchAll() function line. Thanks for any help you guys can offer! Here is the connection script
<?php// Connects to Our Database$db_host = "localhost";$db_user = "root";$db_password = "";$db_database = "game_db";try{ $conn = new PDO ('mysql:host=localhost;dbname=game_db', $db_user, $db_password);$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} catch (PDOException $e) { echo 'ERROR: ' . $e->getMessage();}?>
And the query thats giving me the trouble
$sql = "INSERT INTO `player_data` (`username`, `empire_name`, `ruler_name`, `founding_group`, `government`, `population`, `currency`, `p_currency`, `scrap`, `food`, `fuel`, `salvage_wpn`, `scrap_wpn`, `morale`, `initiative`, `influence`, `farms`, `housing`, `scrap_yards`, `barracks`, `taverns`, `scouts`, `militia`, `infantry`, `heavy_infantry`, `technicals`, `tanks`, `gate`, `tower`, `wall`, `tunnels`, `dogs`) VALUES (:user, :empire_name, :ruler_name, :founding_group, :government, 25, 1000, 100, 1000, 1000, 0, 0, 5, 10, 100, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; $query = $conn->prepare($sql); $query->bindValue(':user', $user, PDO::PARAM_STR); $query->bindValue(':empire_name', $empire_name, PDO::PARAM_STR); $query->bindValue(':ruler_name', $ruler_name, PDO::PARAM_STR); $query->bindValue(':founding_group', $founding_group, PDO::PARAM_STR); $query->bindValue(':government', $government, PDO::PARAM_STR); try { $query->execute(); } catch (Exception $e) { exit($e); } $row_count = $query->fetchAll(PDO::FETCH_ASSOC);