Jump to content

lovephp

Members
  • Posts

    530
  • Joined

  • Last visited

Everything posted by lovephp

  1. Accept it sorry about it
  2. No no its ok delete that post and sorry about it, you all are right i made a mistake i accept it
  3. Ok apologies guys will not repeat this again
  4. Ah yes i just copy pasted to make it simpler for him to understand. Not my code
  5. Hehe why
  6. and if i do $offset = abs(($page - 1) * $per_page); it works too
  7. and this just showing why this also wont work it would show 1 record but the next page is not showing any record $offset = ($page - 1) * $per_page; $start = $offset + 1; $end = max(($offset + $per_page), $total); $query = "SELECT * FROM applied WHERE memberID = :memberID ORDER BY id DESC LIMIT :per_page OFFSET :offset"; $stmt = $db->prepare($query); $stmt->bindParam(':per_page', $end, PDO::PARAM_INT); $stmt->bindParam(':offset', $start, PDO::PARAM_INT); $stmt->bindParam(':memberID', $uid, PDO::PARAM_INT); $stmt->execute();
  8. doing this then if($offset < 0){ $offset = 10; } ?
  9. so i tried something like this but is this the only solution if($offset < 0){ $offset = 10; }
  10. so if i make $offset = ($page - 1) * $per_page; to $offset = ($page + 1) * $per_page; would this make sense? or something like if($offset < 0){ $offset = 10; }
  11. sorry late, well i have no issue and i did thid var_dump($offset); var_dump($per_page); var_dump($uid); and this is what i see on the browser along with the error float(-10) int(10) int(4) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1210 Incorrect arguments to mysqld_stmt_execute'
  12. hehe you are correct and it would be dumb to not use PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION well im not passing 0 but im sure if there is no value in database applied table then 0 gets passed? CREATE TABLE IF NOT EXISTS `applied` ( `id` int(11) NOT NULL AUTO_INCREMENT, `vacancyID` int(11) NOT NULL, `memberID` int(11) NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; it has to be total or offset somewhere the 0 is coming and i m not understanding
  13. and then i removed //$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); then the error disappeared but this sure is no solution is not it?
  14. those questions are going above my head ok my config is like this try { //create PDO connection $db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES,false); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); } catch(PDOException $e) { //show error echo '<p class="bg-danger">'.$e->getMessage().'</p>'; exit; } and all integers are being called from db if that was what you asked? when 0 then there is error else no error. sorry my English understanding is little limited
  15. guess their technical team also are good for nothing. now what other option i have to run those codes? only for the above code i face this error if there is no value in db
  16. they are telling me that i have used a mysqld statement but i cannot seem to find where i have used it, executive asked me to remove that mysqld statement as asked by their technical team
  17. changing version gives me blank page. is it my code or their hosting issue? they tell me its my code which has problem
  18. i feel sad i yesterday bought it its taking forever to send emails too
  19. these are all the versions the host is providing my i tried changing but nothing is happening and i get no option to change the MYSQL version
  20. host provided current PHP version 5.4 i tried changing it to 5.6 5.4 5.5 but still no affect in those other versions the page becomes blank instead.
  21. thanks. both
  22. so the following codes working just fine on wamp and now that i try it on web host i get this error Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1210 Incorrect arguments to mysqld_stmt_execute i get this error if there is no value in db here is the codes $query = "SELECT COUNT(*) FROM applied WHERE memberID = :memberID"; $stmt = $db->prepare($query); $stmt->bindParam(':memberID', $uid, PDO::PARAM_INT); $stmt->execute(); $total = $stmt->fetchColumn(); $pages = ceil($total / $per_page); $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); $offset = ($page - 1) * $per_page; $query = "SELECT * FROM applied WHERE memberID = :memberID ORDER BY id DESC LIMIT :per_page OFFSET :offset"; $stmt = $db->prepare($query); $stmt->bindParam(':per_page', $per_page, PDO::PARAM_INT); $stmt->bindParam(':offset', $offset, PDO::PARAM_INT); $stmt->bindParam(':memberID', $uid, PDO::PARAM_INT); $stmt->execute(); //error states this line $result = $stmt->fetchAll();
  23. But mate i already showed you if $status[1] == 'true' why you trying to compare less than etc?
  24. Share everything including the fetching from db
×
×
  • 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.