I've got a form that's supposed to update a db enty. I have no clue why it won't run. The query works fine in phpmyadmin. I've dumped $_POST and everything has a value. try{ $db = new PDO($dsn, $dbUsername, $dbPassword, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); }catch(\PDOException $e){ echo $e->getMessage();} try{ $sqlUpdateAd = $db->prepare("UPDATE `advertisements` SET `title`= ?,`link`= ?,`image`= ? WHERE `token` = ?"); $sqlUpdateAd->execute(array($_POST['title'], $_POST['link']), $_POST['image'], $_POST['token']); }catch(\PDOException $e){echo $e->getMessage();} echo $_POST['token']; PHP: Even the simple bit of code above is not updating the db, or throwing a messagein $e->getMessage(). Not sure why this isn't working.
Can you echo out the $_POST-variables, and tell us what they contain? You can also change the PDO::ATTR_ERRMODE to PDO::ERRMODE_WARNING to see if it displays anything then.
I solved this dumb problem. I was closing off the array in execute too soon. I have another bit of code though. I'm wondering how to echo out my pagination based on three paginators. I've got one for regular ads, one for sponsored ads, and one for promoted ads. They all display 14 results each, so the code should work easy. If there are more regular ads than sponsored ads or promoted ads regular ads numbers will show if there's more sponsored ads than regular ads or promoted ads sponsored ads numbers will show if there's more promoted ads than sponsored ads or regular ads promoted ads numbers will show That way users can see all types of ads pagainated. The code I have below will only show two. The paginators are $paginator $sponsorPaginator $promotedPaginator if($paginator->return_total_pages() > $sponsorPaginator->return_total_pages()) { echo $paginator->pagination('browse.php?category='.$category.'&subcategory='.$subcategory.'', isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0); }else{ echo $sponsorPaginator->pagination('browse.php?category='.$category.'&subcategory='.$subcategory.'', isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0); } PHP:
You could condense that quite a bit, if you make it into an array. Something like this: $paginators = ['paginator'=>$paginator->return_total_pages(),'sponsorPaginator'=>$sponsorPaginator->return_total_pages(),'promotedPaginator'=>$promotedPaginator->return_total_pages()]; $key = array_search(max($paginators), $paginators); echo $$key->pagination(); //stuff goes here; Code (markup): The $paginators-array contains all the return-values. (Note, if any of them return the SAME value, I think the MAX-function will only return the first - this is a shortcoming, if that matters, but your current code will only show the first one as well the $key-variable contains the key for the max-value And the last line will transform that key into the starting class-variable you need to perform your pagination-setup (since the code looks to be exactly the same across all arrays when it comes to displaying them) I think this should work - only tested without class-calls, since I don't have the actual classes to work with, but it seems to be working as it should.
Thanks, I'll give this a try in bit. Appreciate the help. That was the last thing to get up. Can't have ads not paginating right.