nikos101
09-17-2009, 08:54 PM
Hi all, the following works , but when I use CALL getAudio() I get no result.
<?php
$connection = mysql_connect('localhost', 'root', '');
mysql_select_db('mcomp', $connection) or die(mysql_error());
// $q = "CALL getAudio()";
$q = "SELECT * FROM tbaudio t;";
$result = mysql_query($q, $connection);
while ( $row = mysql_fetch_array ( $result ) ) {
echo $row ["id"];
}
?>
I have verified the sp getAudio() on the query browser
any ideas?
SKDevelopment
09-17-2009, 11:44 PM
Try
SELECT getAudio();
I think it should work ... I always call stored functions via SELECT. I did not call them without the FROM clause but since it is optional in MySQL, I think it should work.
nikos101
09-19-2009, 10:13 AM
That doesn't work either :(
hinch
09-19-2009, 11:41 AM
http://uk3.php.net/pdo.prepared-statements may help
nikos101
09-19-2009, 04:14 PM
http://uk3.php.net/pdo.prepared-statements may help
Could you help me use that with the code I was trying, I am not sure what to do.
nikos101
09-19-2009, 04:20 PM
I tried this
<?php
$connection = mysql_connect('localhost', 'root', '');
mysql_select_db('mcomp', $connection) or die(mysql_error());
$stmt = $connection->prepare("call getAudio()");
$stmt->bindParam(1, $result, PDO::PARAM_STR, 4000);
$stmt->execute();
while ( $row = mysql_fetch_array ( $result ) ) {
echo $row ["id"];
}
/* $q = "SELECT * FROM tbaudio t;";
$result = mysql_query($q, $connection);
while ( $row = mysql_fetch_array ( $result ) ) {
echo $row ["id"];
} */
?>
but got this:
Fatal error: Call to a member function prepare() on a non-object
SKDevelopment
09-19-2009, 04:44 PM
When it is necessary to work with the DB using PDO, mysql_connect() is not used. Please see how to connect to the database here (http://www.php.net/manual/en/pdo.connections.php).
nikos101
10-12-2009, 05:26 PM
This PDO stuff looks complex :)