Jump to content

gabaroar

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by gabaroar

  1. Thank you. That has been driving my nuts
  2. I am having trouble calling mysql_num_rows in my script. I get the error message "PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\scripts\update.php on line 41". I have looked around online but can only find the my sql is not right. I am able to copy and past the sql into mysql workbench and it runs fine. Any help would be much appreciated. $game_id = $row['id']; $game_name = $row['game_name']; print("updating game {$game_id}: {$game_name}" . PHP_EOL); $sql = "SELECT users.id, users.username, users.number_attended_games FROM users join game_sessions_users on game_sessions_users.user_id = users.id where game_sessions_users.game_session_id = " . $game_id; print($sql . PHP_EOL); $players = mysql_query($sql, $connection) or die(mysql_error($connection));; if(mysql_num_rows($players >= 1)){ while($player = mysql_fetch_array($players, MYSQL_ASSOC)){ print('updating player: ' . $player['username']); $number_attended_games = $player['number_attended_games']; $user_id = $player['id']; $sql = "UPDATE users SET number_attended_games = " . ($number_attended_games + 1) . ", user_level = " . ($number_attended_games / 10) . " WHERE id = " . $user_id; $update_result = mysql_query($sql, $connection); } } $sql = "UPDATE game_sessions SET completed = 1 WHERE id = " . $game_id; $update_result = mysql_query($sql, $connection);
  3. I believe something like this <?php $username = $_GET['username']; $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mya2billing", $con); $result = mysql_query("SELECT * FROM cc_card WHERE username='" . $username . "'"); while($row = mysql_fetch_array($result)) { echo $row['credit'] . " " . $row['id']; echo "<br />"; } ?>
  4. Hello What you looking for is a get variable. You can find information with examples here (http://www.w3schools.com/PHP/php_get.asp) I like to use MDB2 for mysql work(http://pear.php.net/package/MDB2/)
×
×
  • 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.