2

I've got a really strange problem.

I'm making an ajax call to the server sending form details to a php script. Using PDO i then insert the values into the database. Firebug returns a 500 error BUT the values ARE INSERTED into the database. I can't find anything in the error log (i looked in apache error log and mysql error log)

I'm running centos 6, php 5.3.3 and mysql 5.1.

I looked through the php sysinfo and saw this in the apache config:

'--disable-pdo'

Not sure if that has anything to do with it, but hey..

Here is the code i'm using:

try {
    $conn = new PDO('mysql:dbname=dbname;host=localhost', 'username', 'password');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $query = $conn->prepare('INSERT INTO sometable (naam, beroep, telefoon, emailadres, bericht, ismedical) 
        VALUES(:naam, :beroep, :telefoon, :emailadres, :bericht, :ismedical)');
    $query->execute(array(
        ':naam' => $naam,
        ':beroep' => $beroep,
        ':telefoon' => $telefoon,
        ':emailadres' => $emailadres,
        ':bericht' => $bericht,
        ':ismedical' => $ismedical
    ));
    echo $stmt->rowCount(); // should be 1
} catch (PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}
Nick
  • 2,862
  • 5
  • 34
  • 68
  • I would if people would actually answer my questions and not be like: your question is vague, when it clearly is not. I asked a couple of questions out of which I've received 1 normal answer. And sometimes I figure it out on my own before a question is answered. Then I go back to try to answer my own question and it tells me I don't have enough rep. Well then I give up -.- – Nick Nov 24 '12 at 19:01
  • see Ortix ain't no dummy – Drew Nov 24 '12 at 19:02
  • http://stackoverflow.com/questions/12169981/pdo-mysql-rowcount-not-returning-as-expected – Drew Nov 24 '12 at 19:24
  • i recreated your error dont know – Drew Nov 24 '12 at 19:25

1 Answers1

1

PDO uses an unbuffered mode by default which leads to lower latency in the page load time and is generally what you want. The trade off is that rowCount() won't return valid information until the entire dataset has been fetched.

Drew
  • 24,851
  • 10
  • 43
  • 78