...

View Full Version : Resolved Can't find the little problem



myfayt
11-17-2011, 06:21 PM
So this should be a quick and easy fix. $sets isn't working. If I remove the IF and ELSE the queries run just fine, but neither query works with the IF ELSE statements.

Help me find the little bug?


$alquery = doquery("SELECT * FROM {{table}} WHERE name='".$userrow['guildname']."' LIMIT 1", "alliances");
$alrow = mysql_fetch_array($alquery);


$me2query = doquery("SELECT * FROM {{table}} WHERE id='$id'", 'smithcreate');
$merow = mysql_fetch_array($me2query);

$sets = doquery("SELECT * FROM {{table}} WHERE name='".$merow['name']."' AND bonusattack='".$merow['bonusattack']."' AND requirement='".$merow['requirement']."' AND type='".$merow['type']."'", "allianceequip");


if (mysql_num_rows($sets) > 0) {
$updatequery = doquery("UPDATE {{table}} SET sets=sets+1 WHERE name='".$merow['name']."' AND bonusattack='".$merow['bonusattack']."' AND requirement='".$merow['requirement']."' AND type='".$merow['type']."' AND allianceid='".$alrow['id']."' LIMIT 1", "allianceequip");
}
else {
$query = doquery("INSERT INTO {{table}} SET id='', type='".$merow['type']."', name='".$merow['name']."', attribute='".$merow['attribute']."', requirement='".$merow['requirement']."', class='".$merow['class']."', bonusattack='".$merow['bonusattack']."', allianceid='".$alrow['id']."', alliancename='".$userrow['guildname']."', sets='1'", "allianceequip");
}

Truffle
11-17-2011, 06:25 PM
have you var_dumped $merow to be sure everything in there is set?

myfayt
11-17-2011, 06:27 PM
Yeah I extracted all variables into an echo and every variable was correct.
But like I said when I remove the if(mysql_num_rows($sets) part it works just fine.

Adee
11-17-2011, 07:26 PM
Yeah I extracted all variables into an echo and every variable was correct.
But like I said when I remove the if(mysql_num_rows($sets) part it works just fine.

that should tell u that $sets is 0 lol

myfayt
11-17-2011, 10:00 PM
Found the problem, needed to add AND allianceid='".$alrow['id']."'
to the sets query.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum