I am going out of my mind, select * from not working.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Breana
    New Member
    • Aug 2007
    • 117

    I am going out of my mind, select * from not working.

    Man i am getting a tumor over this. Ok this morning i noticed my game page was all messed up.
    I moved my site to a new server banner less :) it was all ok last night but now hell.

    So i re did the code and cleaned it up but now it dont work at all.
    It selects the box art but thats it!
    I know its sending the itemid because in the url it shows it.
    item.php?itemid =2

    [PHP]<?
    $itemid = $_REQUEST['itemid'];
    $sql = "select d.title, d.directions, d.gameinfo, d.hits, d.rating, d.userid, c.category, d.gamerating, d.publisher, d.genar, d.screenshots from items d, categories c where d.itemid = $itemid and c.categoryid = d.categoryid";
    $result = mysql_query($sq l ,$db);

    $pagetitle = $myrow["title"];
    $directions = $myrow["directions "];
    $gameinfo = $myrow["gameinfo"];
    $hits = $myrow["hits"];
    $itemrating = $myrow["rating"];
    $userid = $myrow["userid"];
    $category = $myrow["category"];
    $gamerating = $myrow["gamerating "];
    $publisher = $myrow["publisher"];
    $genar = $myrow["genar"];
    $screenshots = $myrow["screenshot s"];
    $username = "Admin";

    if ($userid != 0) {

    $sql = "select login from users where userid = $userid";
    $result = mysql_query($sq l ,$db);
    $username = $myrow["login"];
    }
    $hits++;
    $sql = "update items set hits = $hits where itemid = $itemid";
    $result = mysql_query($sq l ,$db);

    if ($ratevalue) {

    $ratecount = 0;
    $ratetotal = 0;

    $ip = getenv(remote_a ddr);

    $sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

    $result = mysql_query($sq l ,$db);

    if ($myrow = mysql_fetch_arr ay($result)) {
    $ratemsg = "<font color='#FF0000' size='1'>Error: </font> <font size='1'>You have already rated this item</font>";
    } else {
    $sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
    $result2 = mysql_query($sq l ,$db);

    $sql = "select rating from ratings where itemid = $itemid";

    $result3 = mysql_query($sq l ,$db);

    if ($myrow2 = mysql_fetch_arr ay($result3)) {

    do {
    $ratetotal = $ratetotal + $myrow2["rating"];
    $ratecount++;
    }
    while ($myrow2 = mysql_fetch_arr ay($result3)); {

    }

    }

    $newrate = $ratetotal / $ratecount;

    $sql = "update items set rating = $newrate where itemid = $itemid";

    $result4 = mysql_query($sq l ,$db);

    $ratemsg = "<font size='1'>Thank you for rating this $itemlower</font>";

    }

    $itemrating = $newrate;

    }
    ?>[/PHP]
    Last edited by Breana; Sep 16 '07, 11:33 PM. Reason: oops in quote...
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Breana.

    What do you want your code to do? Give an example.
    What is your code doing that you don't want it to do? Give an example.
    What is your code *not* doing that it is supposed to? Give an example.

    Comment

    • Breana
      New Member
      • Aug 2007
      • 117

      #3
      Sorry, it used to get the info by the id=2 and on my page i have code echo it.

      [PHP]Game Name: <?php printf($pagetit le); ?>
      CATEGORY: <?php printf($categor y); ?>
      [/PHP]
      and so on, but it acts like it dont even get the info now?

      Just comes out empty...
      I find it strange over night not toutching it it just dies.... how?

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Breana.

        Did you move your MySQL database over as well? Do you need to change your database connection parameters (Username, password, etc.)? Did you set up permissions for your MySQL Username to access your database?

        Try adding this line below your mysql_query():
        [code=php]
        echo mysql_error();
        [/code]
        to see what's going on.

        Comment

        • Breana
          New Member
          • Aug 2007
          • 117

          #5
          Duh of course i did lol i aint blond, i dont get it..

          i did the error thingie:
          You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

          I just looked and i put a " by misteak lol.

          But nothing shows up now and still no info...

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Breana.

            See if your script is generating any errors.

            P.S., just for you

            Comment

            • Breana
              New Member
              • Aug 2007
              • 117

              #7
              Thanx for the post, man i am going to cry here...
              It says this now.

              You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 14

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 15

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 16

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 17

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 18

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 19

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 20

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 21

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 22

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 23

              Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 24

              Notice: Undefined variable: ratevalue in /home/breana/public_html/item.php on line 37

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Heya, Breana.

                Looks like there's something funny going on with your MySQL query.

                What's your SQL query look like?

                Comment

                • Breana
                  New Member
                  • Aug 2007
                  • 117

                  #9
                  Oh god, look at my url...
                  Its hell opened up and ate my site...



                  um.. you mean this: [code=php]$result = mysql_query($sq l ,$db);[/code]

                  I placed my old item.php before i changed the code and its better not a lot but sone lots of error please help me fix this i dont understand undefined ?

                  Comment

                  • Breana
                    New Member
                    • Aug 2007
                    • 117

                    #10
                    line 131 - last error...
                    Why is it undefined?

                    [PHP]
                    if ($ratevalue) {

                    $ratecount = 0;
                    $ratetotal = 0;

                    $ip = getenv(remote_a ddr);

                    $sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

                    $result = mysql_query($sq l ,$db);

                    if ($myrow = mysql_fetch_arr ay($result)) {
                    $ratemsg = "<font color=\"#FF0000 \" size=\"1\">Erro r:</font> <font size=\"1\">You have already rated this item</font>";
                    } else {
                    $sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
                    $result2 = mysql_query($sq l ,$db);

                    $sql = "select rating from ratings where itemid = $itemid";

                    $result3 = mysql_query($sq l ,$db);

                    if ($myrow2 = mysql_fetch_arr ay($result3)) {

                    do {
                    $ratetotal = $ratetotal + $myrow2["rating"];
                    $ratecount++;
                    }
                    while ($myrow2 = mysql_fetch_arr ay($result3)); {

                    }

                    }

                    $newrate = $ratetotal / $ratecount;

                    $sql = "update items set rating = $newrate where itemid = $itemid";

                    $result4 = mysql_query($sq l ,$db);

                    $ratemsg = "<font size=\"1\">Than k you for rating this $itemlower</font>";

                    }

                    $itemrating = $newrate;

                    }[/PHP]

                    Comment

                    • Breana
                      New Member
                      • Aug 2007
                      • 117

                      #11
                      It keeps yelling at me about this line of code:
                      [code=php]
                      if ($ratevalue) {[/code]

                      Why is it a Undefined variable?
                      Do i need to ad a definition to it...

                      If i change it to this:[code=php]
                      if ($ratevalue = 0)
                      {[/code]

                      It goes away and load the info.. but that does 0 mean...

                      Comment

                      • pbmods
                        Recognized Expert Expert
                        • Apr 2007
                        • 5821

                        #12
                        Heya, Breana.

                        Try changing it to:
                        [code=php]
                        if( ! empty($ratevalu e) )
                        {
                        [/code]

                        Comment

                        • Breana
                          New Member
                          • Aug 2007
                          • 117

                          #13
                          Ok that works:
                          [code=php]
                          if( ! empty($ratevalu e) )
                          {
                          [/code]
                          But it disables the other code, like if already voted error. and so on...
                          When i hit vote it used to say thanks, or sorry you already voted!
                          But now nothing..

                          So should i remove the if statment and make it better?

                          Comment

                          • Breana
                            New Member
                            • Aug 2007
                            • 117

                            #14
                            How can i fix this anyone?
                            Please help.... :(

                            Why is it now defined..

                            [PHP]if ($ratevalue)
                            {

                            $ratecount = 0;
                            $ratetotal = 0;

                            $ip = getenv(remote_a ddr);

                            $sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

                            $result = mysql_query($sq l ,$db);

                            if ($myrow = mysql_fetch_arr ay($result)) {
                            $ratemsg = "<font color=\"#FF0000 \" size=\"1\">Erro r:</font> <font size=\"1\">You have already rated this item</font>";
                            } else {
                            $sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
                            $result2 = mysql_query($sq l ,$db);

                            $sql = "select rating from ratings where itemid = $itemid";

                            $result3 = mysql_query($sq l ,$db);

                            if ($myrow2 = mysql_fetch_arr ay($result3)) {

                            do {
                            $ratetotal = $ratetotal + $myrow2["rating"];
                            $ratecount++;
                            }
                            while ($myrow2 = mysql_fetch_arr ay($result3)); {

                            }

                            }

                            $newrate = $ratetotal / $ratecount;

                            $sql = "update items set rating = $newrate where itemid = $itemid";

                            $result4 = mysql_query($sq l ,$db);

                            $ratemsg = "<font size=\"1\">Than k you for rating this $itemlower</font>";

                            }

                            $itemrating = $newrate;

                            }[/PHP]

                            Comment

                            • Breana
                              New Member
                              • Aug 2007
                              • 117

                              #15
                              Well i give up, its late i am tired thax anyway... :(

                              Comment

                              Working...