need sql help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    need sql help

    hey friends


    i want to direct clear a single coloum by user table

    i use to clear a table this via this php code only run code my table clear

    $db->delete_data("DELETE FROM b_vote");

    but dnt knw how to clear a single row or coloum from the table .....

    dnt do via sql database or myphpadmin

    i want put in php script...


    so help me for that!

    #2
    WHERE voter="'.$voter.'"
    Last edited by something else; 01.03.12, 05:25.

    Comment


      #3
      $db->delete_data("DELETE FROM users WHERE vote="'.$vote.'" ");

      i get this error

      Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\forum\clearvote.php on line 8


      ?

      Comment


        #4
        $db->delete_data( "DELETE FROM users WHERE vote='$uid' ");

        i also put this but give error

        Notice: Undefined variable: uid in C:\wamp\forum\clearvote.php on line 8

        Comment


          #5
          WHERE voter = '$voter'

          or look in the table structure to see if it has the uid or user id column and add this ,

          WHERE uid = '$user_id'

          or


          WHERE user_id = '$user_id'

          depending on how your table is structured

          Comment


            #6
            Originally posted by 12345xmen View Post
            $db->delete_data( "DELETE FROM users WHERE vote='$uid' ");

            i also put this but give error

            Notice: Undefined variable: uid in C:\wamp\forum\clearvote.php on line 8

            Better to use
            Code:
            mysql_query("DELETE FROM users WHERE vote='$uid");
            And yout need to Define $uid
            let
            Code:
            $uid = 1;
            or
            Code:
            $uid = $_GET['id'];

            Comment


              #7
              this is my user table

              CREATE TABLE IF NOT EXISTS `users` (
              `userid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
              `username` text,
              `password` text,
              `email` text,
              `groupid` bigint(20) unsigned NOT NULL DEFAULT '0',
              `rank` varchar(255) NOT NULL DEFAULT '0',
              `vote` bigint(20) unsigned NOT NULL DEFAULT '0',
              PRIMARY KEY (`userid`)
              ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;


              i want its clear users table all vote count form vote colum or row

              now tell me how i do that above way not wrk for me


              this is my vote clear code

              PHP Code:
              <?php
                  
                  
              include "include/init.php"
                  if(
              isloggedin())
                  {
                      if(
              $group[$user->groupid]['type'] == || $group[$user->groupid]['type'] == )
                      {
                  
                      
              $db->delete_data"DELETE FROM users WHERE vote='$vote' ");
                      
                      }
                      else
                      {
                          print 
              "You dont have permission for this."; exit;
                      }
                      
                  }
              ?>
                  
                  <span style="font:normal 10pt verdana;">Votes Cleared</span><br/><br/>
                  
                  
                  <a href="../forum/index.php">Back to home</a> <br/>
              Added after 14 minutes:

              if i put this

              mysql_query("DELETE FROM users WHERE userid= '$userid'");


              wrk fi9 but when i use


              mysql_query("DELETE FROM users WHERE vote= '$vote'");

              get this

              Notice: Undefined variable: vote in C:\wamp\www\forum\clearvote.php on line 9
              Last edited by 12345xmen; 01.03.12, 09:13.

              Comment


                #8
                Originally posted by 12345xmen View Post
                Notice: Undefined variable: vote in C:\wamp\www\forum\clearvote.php on line 9
                $vote isnt assigned to anything

                Comment


                  #9
                  no where i assine for that !

                  Comment


                    #10
                    Originally posted by 12345xmen View Post
                    no where i assine for that !
                    in place of
                    mysql_query("DELETE FROM users WHERE userid= '$userid'");
                    use this code
                    mysql_query("UPDATE users SET vote = 0 WHERE userid= '$userid'");

                    Comment


                      #11
                      thanks dear its wrk thanks lot

                      Comment


                        #12
                        @ faizon dear its wrk perfectly in wampserver

                        but on my web host its not wrk

                        when i clear vote its clear only b_vote votes


                        not update user vote table which set vote = 0

                        i use that

                        $db->delete_data("DELETE FROM b_vote");
                        $db->delete_data("UPDATE users SET vote=0 WHERE userid='$userid' ");

                        its wrk in wampserver but not on bythsot free host !

                        i dnt knw y any other way i do this !

                        Comment

                        Working...
                        X