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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #16
    Heya, Breana.

    I don't see where you define 'ratevalue' anywhere in your code. It seems that it will always be unset, so the code inside the conditional will never execute.

    Did you mean to use $_GET['ratevalue'] or $_POST['ratevalue']?

    Comment

    • Breana
      New Member
      • Aug 2007
      • 117

      #17
      I need to make it better i guess....

      Ok, let me explane it better.
      The form rate game is on the item.php, when you choose vote and hit send it posts the info to the item.php and the sql here is supost to eather send it if you havent voted allready thats why it checks for your ip.

      And eather says:
      Thanks, and records your ip or it says error.

      But it just dont want to do it now for some reason it says undefined?
      So how do i define it, below is all the elements i used.

      Form id:
      [PHP]<form action="item.ph p" method="post" name="vote" id="vote">
      <input type="hidden" name="itemid" value="<?php printf($itemid) ?>" />

      <input type="radio" name="ratevalue " value="5" onClick="this.f orm.submit();" />AWESOME&nbsp ;
      <input type="radio" name="ratevalue " value="4" onClick="this.f orm.submit();" /> GOOD&nbsp;
      <input type="radio" name="ratevalue " value="3" onClick="this.f orm.submit();" />AVERAGE&nbsp ;
      <input type="radio" name="ratevalue " value="2" onClick="this.f orm.submit();" />POOR&nbsp;
      <input type="radio" name="ratevalue " value="1" onClick="this.f orm.submit();" />
      BAD</form>[/PHP]

      SQL code:
      [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)) {
      printf("<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);

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

      }

      $itemrating = $newrate;

      }
      ?>[/PHP]

      And it used to work, if at all possible i would like help making it better :)
      Last edited by Breana; Sep 17 '07, 01:14 PM. Reason: Added code :)

      Comment

      Working...