php - What is wrong with this MySQL Query? -


it's 12:30am , have been coding 9 hours straight. need project done, mysql messing deadline. examine snippet me , see if can find out wrong?

php/mysql query

$q = $this->db->query("select * bans ip='".$ip."'"); 

keeps returning following error...

mysql error [oct 6th, 2010 11:31pm cdt]
have error in sql syntax; check manual corresponds mysql server version right syntax use near '* bans ip='206.53.90.231'' @ line 1 (1064)

i not see wrong query. i've tried different methods of including variable $ip no avail.

edit:
add in here, ip column in database varchar(255).

edit 2:
here whole affected code. keep in mind in class. if i'm missing something, let me know.

line function

if($this->isbanned($_server['remote_addr'])===true) { return json_encode(array('error'=>'you banned shoutbox.')); } 

affected function

function isbanned($ip) {     $q = $this->db->query("select * bans ip='".$ip."'"); $num = $this->db->affected_rows;     if($num>0) { $row = $this->db->fetch_array($q); if(($row['expires'] < time()) && ($row['expires'] !== 0)) { $this->unbanuser($ip,'internal'); return false; } return true; } return false; } 

unbanuser function

function unbanuser($ip,$t='box') {     $q = $this->db->query("select * bans ip='".$ip."'"); $num = $this->db->affected_rows; if($num>0) { $q = $this->db->query("delete * bans ip='".$ip."'");      return (($t=='box') ? json_encode(array('status'=>'removed')) : true); } else { return (($t=='box') ? json_encode(array('error'=>'unable locate user.')) : true); } } 

i think may be delete statement causing error.

remove * after delete , should fine.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -