Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,453
    Thanks
    71
    Thanked 102 Times in 101 Posts

    Can't find the little problem

    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?

    PHP Code:
     $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");
            } 
    Last edited by myfayt; 11-17-2011 at 09:01 PM.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #2
    New Coder
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    80
    Thanks
    1
    Thanked 8 Times in 8 Posts
    have you var_dumped $merow to be sure everything in there is set?

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,453
    Thanks
    71
    Thanked 102 Times in 101 Posts
    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.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by myfayt View Post
    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

  • #5
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,453
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Found the problem, needed to add AND allianceid='".$alrow['id']."'
    to the sets query.
    Been a sign maker for 7 years. My business:
    American Made Signs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •