Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP timeout when writing to mysql
    text
    copied!<p>I keep getting a timeout when I execute the code below. Here's the exact error:</p> <p><code>Warning: PDO::__construct() [pdo.--construct]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in D:\xampp\htdocs\logansarchive\admin\articlework.php on line 16 Fatal error: Maximum execution time of 60 seconds exceeded in D:\xampp\htdocs\logansarchive\admin\articlework.php on line 0</code></p> <p>I feel that it is worth noting that between the time when this DID work and when it DIDN'T, nothing was changed on my web server or in this code.</p> <p>Here's the code that does the work in the database:</p> <pre><code>&lt;?php $action = $_REQUEST["action"]; $target = $_REQUEST["target"]; $srctitle = $_POST["srctitle"]; $title = $_POST["article_title"]; $cat = $_POST["article_cat"]; $content = $_POST["article_content"]; // Set database server access variables: $host = "localhost"; $user = "root"; $pass = "root"; $db = "logansarchive"; // Open connection $dbh = new PDO('mysql:host='.$host.';dbname='.$db, $user, $pass); $date = date('Y-m-d H:i:s'); switch ($action) { case "Edit": $query = $dbh-&gt;prepare("UPDATE Articles ". "SET ArticleTitle = :title, Category = :cat, ArticleDate = :date, ArticleContent = :content ". "WHERE ArticleTitle = :srctitle"); $query-&gt;bindParam(':title', $title); $query-&gt;bindParam(':cat', $cat); $query-&gt;bindParam(':date', $date); $query-&gt;bindParam(':content', $content); $query-&gt;bindParam(':srctitle', $srctitle); $query-&gt;execute(); break; case "New": $query = $dbh-&gt;prepare("INSERT INTO Articles(Category, ArticleDate, ArticleTitle, ArticleContent) ". "VALUES(:cat, :date, :title, :content)"); $query-&gt;bindParam(':cat', $cat); $query-&gt;bindParam(':date', $date); $query-&gt;bindParam(':title', $title); $query-&gt;bindParam(':content', $content); $query-&gt;execute(); break; case "Delete": if ($target != "") { $query = $dbh-&gt;prepare("UPDATE Articles ". "SET DeletedYN = :del ". "WHERE ArticleTitle = :title"); $query-&gt;bindValue(':del', "Yes"); $query-&gt;bindParam(':title', $target); $query-&gt;execute(); } else { header("Location: index.php?result=failed"); } break; } header("Location: index.php?result=success"); ?&gt; </code></pre> <p><strong>EDIT 1:</strong> I just realized something that may narrow down the cause of the problem. The code above is the only part of the website where I'm using PDO. All the rest uses mysql_* and it all works fine. This leads me to believe that the problem lies with PDO.</p>
 

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