Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP update script does not do anything and throws no error
    primarykey
    data
    text
    <p>Iv'e got a site that has a button on every page. When the button is clicked, it calls a function, <code>readAllNotifs</code>:</p> <pre><code>function readAllNotifs() { $('#ticker').fadeTo(0,0); $.get('scripts/readAllNotifs.php'); } </code></pre> <p>and here's scripts/readAllNotifs.php :</p> <pre><code>&lt;?php session_start(); require '../PDOconnection.php'; if (!isset($_SESSION['uID'])) { $_SESSION['interPageMessage'] = "You need to login to view this page"; header("location: ../login.php"); die(); } $query = $DBH-&gt;prepare("UPDATE notifications SET readStatus = 'true' WHERE uID = ? ORDER BY readStatus DESC LIMIT 10"); $query-&gt;bindparam(1,$_SESSION['uID']); $query-&gt;execute(); ?&gt; </code></pre> <p>Now on every page, this works as expected. I click on the button, <code>#ticker</code> disappears and i look at my database, the rows have been updated. However, on 1 particular page, it doesn't work... I have no idea why...</p> <p>When I click on the button,<code>#ticker</code> disappears (So i know the function IS being called).. then I checked if the reason it isn't working is if the file i'm talking about is in a different directory (then scripts/readAllNotifs.php would be wrong). But no, it's in the same directory with the files for the other pages (the ones for which this works perfectly). So I looked at my (Chrome) Developer Tools, looked at the Network tab, and when i clicked the button, I couldn't see a request sent to that page. I thought that was weird, so I checked the other files on which this works perfectly, but even there, the Network tabe DOES NOT SHOW a call to readAllNotifs.php, but it still works. So then, I switched to the console, right clicked and selected Log XMLHttpRequests... And now, when I click the button, I can see this: <code>XHR finished loading: "http://localhost/trunk/scripts/readAllNotifs.php".</code> But still, checked my database. No change.</p> <p>So I tried again, I changed the last line on the php file from this</p> <pre><code>$query-&gt;execute(); </code></pre> <p>To this:</p> <pre><code>$query-&gt;execute() or die(var_dump($query-&gt;errorinfo())); </code></pre> <p>And then went to all the pages on the site, the problematic page included, and I checked the network tab, still no record of calling this page. Then I just went straight to scripts/readAllNotifs.php in my browser. It loaded a blank page (SUCCESS!) I checked the DB, and yeah, the values got updated.</p> <p>Now what doesn't make sense is that if the php file works perfectly, if the function call works perfectly, the SQL syntax is perfect, the PDO execution doesn't output an error, if the page is in the right directory, if the other files in the same directory can perform this perfectly... Then why can't this page?</p> <p>P.S. The Javascript involved in this is saved on an external .js file and is linked to every page on the site using script tags. Also, this script tag comes before all the other script tags on the page (except the one used to include jQuery.js) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload