Jump to content


  • Posts

  • Joined

  • Last visited

Darkranger85's Achievements


Newbie (1/7)



  1. Do you have a tutorial in mind for the exercises? So far, I've yet to find an AJAX tutorial that I like so I would be happy for any suggestions. Or if you would like to give me a short HW assignment I'd be happy to follow.
  2. Hey all, I'm trying to get into AJAX and I'm having a hard time at the moment. I think that if I can get some help putting together one good first one I might be able to improve from there. Here is what I'm trying to accomplish: I have a PHP file called init.php which is included into the top of my pages. In this file is a PHP array called $errors which contains error messages when a user does something wrong (no username and password etc etc). In my PHP when an error is detected in this array an error message comes up on the page and lists the errors. Eventually I would like to replace this with a nice jQuery animation where the error message slides down and has a button to slide it back up. So, I figure the first step is I need to import the PHP error array into jQuery. Now, I've looked up numerous tutorials on AJAX and I can't get it into my head. Would someone help me setup this array transfer so that I can play with it and learn from the process? And I'm not looking for anyone to do it for me. If you want to make me work a bit for it that's fine, just as long as the instruction is clear and easy to understand. Thanks guys! I appreciate it!
  3. Wow. . . I was watching the tutorial and I just ended up adding it to the mysql statement I had up at the time, which was the wrong one. I should have noticed that obviously an inset query wouldn't return rows. . . Now that thats finished, could you guys help me out getting the hang of this. I'm trying to "translate" this code into PDO but I'm having a hard time getting the hang of accessing the array that is returned. $query_select = "SELECT 'username', 'empire_name', 'ruler_name' FROM `player_data` WHERE `username`='$user'"; $result_select = mysql_query($query_select); $rows_select = mysql_fetch_assoc($result_select); $num_rows_select = mysql_num_rows($result_select); $val_empire = $rows_select['empire_name']; $val_ruler = $rows_select['ruler_name']; if ($num_rows_select === 1 || !empty($rows_select['username'])){ $errors[] = "Username is already taken."; } if ($val_empire === $empname){ $errors[] = "Empire name is already taken."; if ($val_ruler === $ruler){ $errors[] = "Ruler name is already taken."; } }
  4. PDOException: SQLSTATE[HY000]: General error in C:\wamp\www\Projects\Planet Ruin\php\regval.php on line 142
  5. 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);
  • Create New...