tags:

views:

12

answers:

1

Is there any way to turn on driver logging for PHP/MySQL 5? Is there a log that shows internally what's going on... like all database activity? Lower-level errors?

I'm trying to get a trivial PHP page to call a trivial stored proc on Windows 7. mysql_error isn't returning any error message when the mssql_init() fails.

Thinking it might be a permission problem I created a new user and I get the same results:

CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';
GRANT ALL ON *.* TO 'user1'@'localhost';

Here is the code:

create table trace (
    trace varchar(50) not null,
    datet datetime not null
);

drop procedure if exists mark;
delimiter !!
create procedure mark()
begin
    insert into trace (trace,datet) values ('mark',now());
end; !!
delimiter ;

I can call the SP from MySQL Workbench just fine:

call mark();

Here is the PHP page:

<?php
$connection = mysql_connect('localhost', 'user1', 'pass1');
if (!$connection) {
    die('Could not connect: ' . mysql_error());
}

$sel = mysql_select_db('tw');
if (!$sel) {
    die('Could not select_db: ' . mysql_error());
}

//$stmt = mssql_init('mark', $connection);
//$stmt = mssql_init('mark', $sel);
$stmt = mssql_init('mark');
if (!$stmt) {
    die('Could not init: ' . mysql_error());
}

$result = mssql_execute($stmt);
if (!$result) {
    die('Could not execute: ' . mysql_error());
}

mysql_free_result($result);

mssql_free_statement($stmt);

mysql_close($connection);

printf("DONE<br />"); 
?>

Other proof of concept pages which demonstrate insert, *select,* etc, are working just fine. Just can't get a stupid stored procedure to run from a web page!

The page output is only this:

Could not init:

(The PHP mssql_init documentation page isn't very helpful and seems to have a typo as the $link variable isn't defined.)

A: 

You're using mssql_init (Note MS SQL) to execute a stored procedure on My SQL.

Obviously the mssql_init() function can't find your Microsoft SQL Server connection 'cause you don't have one. You should only be using mysql_ functions for a MySQL connection.

And MySQL doesn't have a special function for calling stored procedures. mysql_query('CALL mark()') will work just fine.

VoteyDisciple
OMG DOH! I need more sleep and/or caffeine. Sorry to waste your time. Thanks!
Pete Alvin