need sql help

Started on the old forum in March 2012 · view the original in the archive · old links redirect here

11 replies · 571 views · started 14 years ago · 1 min read

5 participants
12345xmen Developer · 239 posts #1

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!

12345xmen Developer · 239 posts #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

?

12345xmen Developer · 239 posts #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

razzbee Developer · 130 posts #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

shushant Developer · 207 posts #6

12345xmen wrote: $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

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

And yout need to Define $uid let

$uid = 1;

or

$uid = $_GET['id'];
12345xmen Developer · 239 posts #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
	
	include "include/init.php"; 
	if(isloggedin())
	{
		if($group[$user->groupid]['type'] == 3 || $group[$user->groupid]['type'] == 4 )
		{
	
		$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

12345xmen Developer · 239 posts #9

no where i assine for that !

faizon Junior · 11 posts #10

12345xmen wrote: 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'");

12345xmen Developer · 239 posts #11

thanks dear its wrk thanks lot

12345xmen Developer · 239 posts #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 !

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close