Convert to PDO Statement

What does $q1->debugDumpParams();

give you after executing, it should show the exact SQL and data passed?

Nothing???

Do you have php error reporting switched on? I’d also try throwing a deliberate error with the connection/prepared statement to see what happens, but it looks like there’s something amiss with PDO as you’re neither getting an error but also not getting any output at all from the debug.

In these kinds of scenarios I’d create a new test script that is literally a few lines that only processes the most simple PDO transaction you can, with no other dependencies or other points of failure. I’d switch on mysql logging in a staging environment and then see whether anything gets processed at all.

For whatever it’s worth, your PDO didn’t work on my work computer, but it did work on my home computer. So the code itself is fine. The problem might be other software interfering with the MySQL connection, or a different MySQL version, different PHP version, or different PDO version.

I am running this on my local machine using PHP 5.3.6, Apache 2.2.19 and MySQL 5.0.8. The frustrating thing is I have this PDO statement which works 100%

    try { 

  $r = "INSERT INTO `property`(`propertyref`) VALUES (:propertyref)";
   $q1 = $dbh->prepare($r);
   $q1->bindvalue(":propertyref", $_REQUEST['propertyref']);

 $q1->execute();
   
  $_REQUEST['id']=$dbh->lastInsertId(); // GET LAST id FROM DB


 
} catch (PDOException $e) {
    print "Error Inserting New Data!: " . $e->getMessage() . "<br/>";
    die();
} 

OK Had some time to work with this during the morning and discovered the culprit is related to these statements



for($i=0;$i<count($_FILES['foto']['tmp_name']);$i++): // Loop through array of images

if($_FILES['foto']['tmp_name']['$i']): // OBVIOUSLY NOT BECAUSE QUERY DOES NOT RUN


The array prints as

Array ( [name] => Array ( [0] => featured.jpg [1] => calendar.jpg [2] => buyers.jpg [3] => beach.jpg [4] => search_image.jpg [5] => search-button.jpg [6] => [7] => [8] => [9] => ) [type] => Array ( [0] => image/jpeg [1] => image/jpeg [2] => image/jpeg [3] => image/jpeg [4] => image/jpeg [5] => image/jpeg [6] => [7] => [8] => [9] => ) [tmp_name] => Array ( [0] => C:\Windows\Temp\php8FE2.tmp [1] => C:\Windows\Temp\php8FF3.tmp [2] => C:\Windows\Temp\php9013.tmp [3] => C:\Windows\Temp\php9014.tmp [4] => C:\Windows\Temp\php9015.tmp [5] => C:\Windows\Temp\php9016.tmp [6] => [7] => [8] => [9] => ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 4 [7] => 4 [8] => 4 [9] => 4 ) [size] => Array ( [0] => 167178 [1] => 1679334 [2] => 13781 [3] => 12195 [4] => 1955 [5] => 48297 [6] => 0 [7] => 0 [8] => 0 [9] => 0 ) )

echoing value of $i gives
value is now 0
value is now 1
value is now 2
value is now 3
value is now 4
value is now 5
value is now 6
value is now 7
value is now 8
value is now 9

So the loop is working

No values for tmp_name ??

[‘$i’]

should be

[$i]

GROAN!! Thanks :slight_smile: