为什么这个存储过程不起作用?

It doesn't seem like there is a problem, I can't understand why doesn't return data.

This is my stored procedure:

DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`get_products`$$
CREATE PROCEDURE  `test`.`get_products`
(
    OUT out_productName VARCHAR(255)
)
BEGIN
SELECT productName INTO out_productName FROM products;
END $$
DELIMITER ;

and this is how I call it:

$rs = mysql_query( 'CALL get_products(@f)' );
$rs = mysql_query( 'SELECT @f' );
while($row = mysql_fetch_assoc($rs))
{
print_r($row);
}

this doesn't quite answer your question but a work around is to just not to use the output parameter

DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`get_products`$$
CREATE PROCEDURE  `test`.`get_products`
(

)
BEGIN
SELECT productName INTO @f FROM products;
END $$
DELIMITER ;


 mysql_query( 'set @f = 0;' );
$rs = mysql_query( 'CALL get_products()' );
$rs = mysql_query( 'SELECT @f' );
while($row = mysql_fetch_assoc($rs))
{
print_r($row);
}

@f will be maintained by the database and can be accessed for the sql session, if I remember correctly

also in the event that you would be returning things while getting results from the stored procedure you would also want to use

$rs->close();
 $connection->next_result();

connection would be whatever you named your connection string

Try:

DELIMITER $$
DROP PROCEDURE IF EXISTS test.get_products;
CREATE PROCEDURE  test.get_products()
BEGIN
SELECT productName FROM products;
END $$
DELIMITER ;

And call it:

$rs = mysql_query( 'CALL test.get_products()' );
while($row = mysql_fetch_assoc($rs))
{
    print_r($row);
}