Jump to content

mysql_num_rows problem


iStriide

Recommended Posts

My table in weapons is wiped clean, but this bit of code will not work for some odd reason.

<?php

$achievements = "SELECT * FROM weapons WHERE Username = '$session'";
$run_achievements = mysql_query($achievements) or trigger_error(mysql_error());
$num_weapons = mysql_num_rows($run_achievements);

if($num_weapons >= 1){

}else{

$date = date("m-d-Y");

$find_gamerscore = "SELECT Attack FROM stats WHERE Username = '$session'";
$run_gamerscore = mysql_fetch_array(mysql_query($find_gamerscore)) or trigger_error(mysql_error());

$other_attack = $run_gamerscore['Attack'];

$gamerscore = $player_gamerscore + 10;
$attack = $other_attack + 15;

// Some of the varibales are from other parts of the code, and they do work

mysql_query("INSERT INTO achievements SET Username = '$session', Achievement_Name = 'Your first weapon!', Achievement_Image = '$weapon_image', Achievement_Description = 'You earned this achievement by buying your first ever weapon.', Achievement_Score = '10', Achievement_Reward_Name = 'Increased Attack +15', Date = '$date'");
mysql_query("UPDATE stats SET Gamerscore = '$gamerscore', Attack = '$attack' WHERE Username = '$session'") or trigger_error(mysql_error());

echo "$gamerscore && $attack && $date";

}

?>

Link to comment
Share on other sites

What do you mean by it "it will not work"? You have to give us some information to go on.

 

Are you getting errors, is it doing something differently than you expect? If so, what is it doing and what is it supposed to do.

 

 

EDIT:

 

This is probably your problem

$run_gamerscore = mysql_fetch_array(mysql_query($find_gamerscore)) or trigger_error(mysql_error());

 

Runt he query first THEN fetch the results

$result = mysql_query($find_gamerscore) or trigger_error(mysql_error());
$run_gamerscore = mysql_fetch_array($result) or trigger_error(mysql_error());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.