Jump to content

fear126

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by fear126

  1. thanks it worked like a charm
  2. oh ok thanks i didnt get that in mind ill give it a try thanks for help
  3. Hi i am having trouble with my ajax code. It take 1st result data-id data and post to other page but it not doing that for all but there is all created exact same using foreach loop. Here is code and images foreach ($companySystem->getAllCompanyGroups($companySystem->getAllCompanyData()->id) as $value) { if(System::checkOddEvent($srNo) == true){ echo " <tr class='odd gradeX'> <td>$srNo</td> <td>".System::removeUnderscore($value->groupName)."</td> <td>$value->createdDate</td> <td class='center'>$value->createdBy</td> <td class=''> <button type='button' id='cmpEditBtn' class='btn btn-warning' data-id='".$value->id."' data-toggle='modal' data-target='#editCompanyGroup'><span class='fa fa-edit fa-large'></span> Edit</button> <button type='button' class='btn btn-danger' data-toggle='modal' data-target='#removeCompanyGroup'><span class='fa fa-ban'></span> Remove</button> </td> </tr> "; }else{ echo " <tr class='even gradeX'> <td>$srNo</td> <td>".System::removeUnderscore($value->groupName)."</td> <td>$value->createdDate</td> <td class='center'>$value->createdBy</td> <td class=''> <button type='button' id='cmpEditBtn' class='btn btn-warning' data-id='".$value->id."' data-toggle='modal' data-target='#editCompanyGroup'><span class='fa fa-edit fa-large'></span> Edit</button> <button type='button' class='btn btn-danger' data-toggle='modal' data-target='#removeCompanyGroup'><span class='fa fa-ban'></span> Remove</button> </td> </tr> "; } $srNo++; } Ajax : <script> $('#cmpEditBtn').on('click',function(e){ $.ajax({ type:'POST', url :"editCompanyGroupAjax.php", data: "id="+ $(this).attr('data-id'), dataType: 'json', success: function(data) { $("#previousCmpName").val(data.groupName); }, error:function(exception){alert('Exeption:'+exception);} }); e.preventDefault(); }); </script> Images : All working fine if i click on first edit button : Not working for other options sorry for bad english
  4. can i please email you full file so you can look over it ?
  5. problem is that the "?" in query are not getting replaced with the values i am supplying in array. But in function attachValues $para is having the arguments which are getting passed but they are not getting bind in query that is problem if you want i can send you whole file run and take a look on it
  6. no error just that query is getting generated Using input : $registerFields = array( "Name" => "qwerty", "username" => "qwerty", "password" => "qwerty", "email" =>"[email protected]", "active" => '1', "lastLogin" => "", "ip" => "", "resetToken" => "", "resetStatus" => "0" ); $userSystem->addNewUser($registerFields);
  7. i enter all columns names but still values are not getting bind in query :S string(154) "insert into `users` (`name`, `username`, `password`, `email`, `active`, `lastLogin`, `ip`, `resetToken`, `resetStatus`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
  8. i need help i created a attachValues function which will attach values to sql query and execute it. I am using SQLITE database using PDO. Here is my code : private function attachValues($sqlQuery, $params = array()) { if ($this->_query = $this->_database->prepare($sqlQuery)) { $binder = 1; if (count($params)) { foreach ($params as $para){ $this->_query->bindValue($binder, $para); $binder++; } } if ($this->_query->execute()) { return true; } else { return false; } } return $this; } public function addNewUser($data = array()){ if (count($data)) { $keys = array_keys($data); $values = ''; $binder = 1; foreach ($data as $field) { $values .= '?'; if ($binder < count($data)) { $values .= ', '; } $binder++; } $sqlQuery = "insert into `users` (`" . implode('`, `', $keys) . "`) VALUES ({$values})"; var_dump($sqlQuery); if ($this->attachValues($sqlQuery, $data) != false) { return true; } } return false; } Error Message : with query dump string(81) "insert into `users` (`name`, `username`, `password`, `email`) VALUES (?, ?, ?, ?)" Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 19 users.active may not be NULL' in /home/u972751794/public_html/billing/classes/UserSystem.class.php:98 Stack trace: #0 /home/u972751794/public_html/billing/classes/UserSystem.class.php(98): PDOStatement->execute() #1 /home/u972751794/public_html/billing/classes/UserSystem.class.php(122): UserSystem->attachValues('insert into `us...', Array) #2 /home/u972751794/public_html/billing/login.php(69): UserSystem->addNewUser(Array) #3 {main} thrown in /home/u972751794/public_html/billing/classes/UserSystem.class.php on line 98
×
×
  • 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.