Jump to content

update query problem help plz


smokyyyyyy

Recommended Posts

im getting error when i run the page

Database Query Failed: 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 '' at line 1

my query is

public function update(){

global $db;

$sql= "UPDATE user SET ";

$sql.= "username='". $db->mysql_prep($this->username) ."', ";

$sql.= "password='". $db->mysql_prep($this->password) ."', ";

$sql.= "firstname='".$db->mysql_prep($this->firstname) ."', ";

$sql.= "lastname='". $db->mysql_prep($this->lastname) ."' ";

$sql.= "WHERE id=". $db->mysql_prep($this->id);

$db->query($sql);

return ($db->affected_rows()==1)?true:false;

Link to comment
Share on other sites

i have echo query

it shows this result

Database Query Failed: 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 '' at line 1

 

Last Query: UPDATE user SET username='', password='jimmy', firstname='', lastname='pakistan' WHERE id=

Link to comment
Share on other sites

thsese are my functions

public function update(){

  global $db;

  $sql= "UPDATE user SET ";

  $sql.= "username='". $db->mysql_prep($this->username) ."', ";

  $sql.= "password='". $db->mysql_prep($this->password) ."', ";

  $sql.= "firstname='".$db->mysql_prep($this->firstname) ."', ";

  $sql.= "lastname='". $db->mysql_prep($this->lastname) ."' ";

  $sql.= "WHERE id=". $db->mysql_prep($this->id);

  $db->query($sql);

  return ($db->affected_rows()==1)?true:false;

 

query function used in update function is

public function query($sql){

$this->last_query= $sql;

$result= mysql_query($sql,$this->connection);

$this->confirm_query($result);

return $result;

 

confirm query function used in query is

 

private function confirm_query($result){

if(!$result){

$output = "Database Query Failed: ". mysql_error()."<br/><br/>";

$output.= "Last Query: ". $this->last_query;

die($output);

 

}

}

error i got is

Database Query Failed: 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 '' at line 1

 

Last Query: UPDATE user SET username='', password='jimmy', firstname='', lastname='pakistan' WHERE id=

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.