Jump to content

CagedApe

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

CagedApe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you Pikachu! That works perfectly.
  2. Thanks. That pointed out my error and now the select command isn't giving an error. However, now its telling me mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Any ideas? $q = "SELECT COUNT(*) AS count FROM attack WHERE attacker_id = $AttackerId AND defender_id = $AttackedId AND attacktime BETWEEN DATE_SUB(NOW(), INTERVAL 1 HOUR) AND NOW()"; mysql_query($q) or die('<br />Query string: ' . $q . '<br />Produced error: ' . mysql_error() . '<br />'); $row = mysql_fetch_array($q) or die(mysql_error()); if($row['count'] == 3){ die("You have already attacked this person 3 times this hour."); }
  3. This should probably be in Javascript help...
  4. I've written out the following, but it returns a syntax error near the bolded portion. I don't see anything wrong with the syntax, but I'm sure theres something I missed. The script is supposed to scan the table to see if you have attacked your current target player 3 times in the last hour. $q = mysql_query("SELECT COUNT(*) AS count FROM attack WHERE attacker_id = $AttackerId AND defender_id = $AttackedID AND attacktime BETWEEN DATE_SUB(NOW(), INTERVAL 1 HOUR) AND NOW()") or die(mysql_error()); $row = mysql_fetch_array($q) or die(mysql_error()); if($row['count'] == 3){ die("You have already attacked this person 3 times this hour.");
  5. I changed that but still get the same error. What else did you see that might be wrong?
  6. I keep getting the error: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I can't see the problem in my code. Any ideas? $message = $_POST['message']; $senderid = $SESSION['SESS_MEMBER_ID']; $recipient = $_POST['recipient']; $q = mysql_query("SELECT * FROM members WHERE member_id = $senderid"); $row = mysql_fetch_array($q); ///error says this is the bad line $sender = $row['username'];
  7. You'd do this: echo ' <tr> <td>'."<a href='profilepage.php?id=$ids'>$ids[$i]".'</a></td> Then your profilepage will use $_GET to find their username like this: if (isset($_GET['id']) && $_GET['id']!='') { $UserId=$_GET['id']; }
  8. Are you simply asking how to put a link in your result? If so this is how you'd do it. Change echo ' <tr> <td>'.$ids[$i].'</td> to echo ' <tr> <td>'."<a href='profilepage.php'>$ids[$i]".'</a></td>
  9. I have a page called attack.php. Everything works except when I try to get $defender_name. I have a feeling there's something wrong with my second sql query, but I'm still a noob so I can't see it. I would appreciate some help from the resident experts session_start(); include "config.php"; //Get AttackId from url if (isset($_GET['id']) && $_GET['id']!='') { $AttackId=$_GET['id']; } //Select attack info(defender's id, winner's id) $q=mysql_query("SELECT * FROM attack WHERE attackid = $AttackId"); $row = mysql_fetch_array($q); $defender_id = $row['defender_id']; // Find defender's username $q1="SELECT login FROM members WHERE member_id = $defender_id"; $row2 = mysql_query($q1); $defender_name = $row2['login']; //Show result if ($_SESSION['SESS_MEMBER_ID'] = $row['winner_id']){ echo "You have defeated ". "$defender_name"; } else{ echo "You have been defeated by ". "$defender_name"; }
  10. Sorry I guess i should have explained a bit better. $row['login'] returns a username. In any event that worked for me, thank you very much! I'm sure I'll be back to ask more questions, but for now thanks and good luck.
  11. I'm trying to add a hyperlink to the results of an array I'm pulling. This is the code I have: $query=("SELECT * FROM members"); $result=mysql_query($query); while($row = mysql_fetch_array($result)){ echo $row['login']; echo "<br />" ; } ?> How would I edit echo $row['login'] to display the result as a hyperlink? Thanks in advance.
×
×
  • 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.