为什么我的PHP停止工作?

I have some complex code. Complex, but it was working.

The I wanted to add some new code, realized that something needed to become a function and then went on a refactoring rampage. Now my code no longer works.

So I did a bit of file compare, some code reading and debugging, and convinced myself that my changes hadn't broken anything.

To test this theory, I put together an exceedingly simple test program:

<?php 
$connection = odbc_connect("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=mysql;Option=3;", "root", "");
var_dump($connection);
echo '<br>';
  $result = @odbc_exec($connection, 'show version()');
  var_dump($result);
?>

which resulted in

resource(2) of type (odbc link) 
bool(false)

The strange thing is that the odbc_connect() succeeds, but the simplest MySql command I can think of fails.

Btw, I have tested at the command line & the MySql server is up & running (Xampp) and reports v 5.1.41.

Obviously I am overlooking something very basic, but what?

Maybe the odbc driver "wants" to tell you something about what is causing the error...

$result = @odbc_exec($connection, 'show version()');
if ( !$result ) {
  printf("error: %d %s", odbc_error($connection), odbc_errormsg($connection));
}
else {
  echo "ok";
}

see http://docs.php.net/odbc_error and http://docs.php.net/odbc_errormsg

This is the simplest MYSQL query I can think of:

select 1

This should help you determine if your connection is working or if the problem lies elsewhere.