By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

value update by using class

P: 12
Expand|Select|Wrap|Line Numbers
  1. function changeusername($username)
  2.     {
  3.         $data['username']    =    $username;
  4.         $ans = $this->db->update_query("indiagren_admin",$data,"username!=' '");
  5.         echo "ANS".$ans;
  6.     }
  7.  
  8.  
  9. function update_query($filename,$data,$where)
  10.     {
  11.         $sql= "UPDATE ".$filename." SET ";        
  12.         foreach ($data as $key=>$value)
  13.         {
  14.             $sql.=$key."=.$value";
  15.         }
  16.  
  17.         $sql = rtrim($sql) . ' WHERE '.$where.';';
  18.         echo " ".$sql."<br>";
  19.         $run = mysql_query($sql) or die (mysql_error());
  20.  
  21.     }
give the error on update query :-

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 'WHERE username!=' '' at line 1
Feb 8 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,366
Output the sql string and show us what that looks like.
Feb 8 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.