MySQL-PHP syntax error when outputting via php (there seems to be none) -


for reason code of mine wont go through, im darn right sure syntax of proper yet won't go. please help!

insert users(username, name, password, type, accounts_prefix, comments, 0, 1, status) values('testuser', 'testuser', 'abc2', 'rslr', 'tes', 'testuseremailcom', 'username_owner', null, 'a') 

you have error in sql syntax; check manual corresponds mysql server version right syntax use near '0, 1, status) values('testuser', 'testuser', 'abc2', 'rslr', 'tes', 'testuserema' @ line 1

edit: insert function:

    function db_insert( $table, $values ) {     if( count($values) == 0 ) return false;      $sql = "insert $table(";     foreach( $values $name => $value )     {         $sql .= $name.", ";     }      $sql = substr($sql, 0, strlen($sql) - 2).") values(";     foreach( $values $name => $value )     {         if( gettype( $value ) == "string" )         {             if( $value == "[null]" )                 $sql .= "null, ";             else                 $sql .= "'".$value."', ";         }         else             $sql .= $value.", ";     }     $sql = substr($sql, 0, strlen($sql) - 2).")";      echo $sql."|";     $result = mysql_query($sql);     echo mysql_error()."|";     return $result; } 

the insert command

if( !db_insert("users", array(         "username" => $_request["r_username"],         "name" => $_request["r_name"],         "password" => $_request["r_password"],         "type" => "rslr",         "accounts_prefix" => $_request["r_prefix"],         "comments" => $_request["r_comments"],         "username_owner", $_request["r_username_owner"],         "status" => "a")     ) )     {         echo("not ok failed add"); } 

most because 0 , 1 shouldn't columns names


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -