RE: Regarding functions in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,Thank you very much.But with out closing the connection also I tried but i got same error please once tried tell me.

Alligator <alligator_666@xxxxxxxxx> wrote:          You are closing the Database connection on the last line of Getrating( ),
So, when the time comes to execute GetAssignedvalue the database object still valid, but the connection is closed and no prepared statement can be returned, thus causing the mysqli_stmt_execute function to fail.

Alligator_666
http://www.vicxsite.com/

Vijaya Lakshmi <nanna_vijayalaxmi_vsp@xxxxxxxxxxx> wrote: hi,
thank you very much for your response.Please some sample code.As your suggesitions i implemented sample application.Please go through following code.Actually I wrote code for stored procedures.It is working fine but when we go for functions we are facing problem.
I wrote code like this
In connection.php
<?php
global $db;
$db=new mysqli("localhost","root","vijaya","vijaya");
?>
In samplefun.php page

<?php
require_once("connection.php"); 
require_once("function_26.php");
$url="www.sciencedaily.com";

$rate=Getrating($url);
echo $rate;echo "<br/>";
$assigned=GetAssignedvalue($url,$rate);
echo $assigned;
?>

in function_26.php page

<?php

function Getrating($url)
{
global $db;
$stmt=$db->prepare( "call rating('$url')");
mysqli_stmt_execute($stmt);
$result=$stmt->bind_result($rating);
mysqli_stmt_fetch($stmt);
$stmt->close();
return $rating;
$db->close();

}
function GetAssignedvalue($url,$rating)
{
global $db;
$stmt=$db->prepare("call Get_Assigned_value('$url',$rating);");
mysqli_stmt_execute($stmt);
$result=$stmt->bind_result($assigned);
mysqli_stmt_fetch($stmt);
$stmt->close();
return $assigned;
}

?>

In above example I wrote code for call stored procedures.when executing this example I got value first function only.But for second i error like following.

Here is Error We got:

[Thu Dec 27 12:03:44 2007] [error] [client 127.0.0.1] PHP Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in F:\\Softwares\\php\\htdocs\\samples\\function_26.php on line 19
[Thu Dec 27 12:03:44 2007] [error] [client 127.0.0.1] PHP Fatal error: Call to a member function bind_result() on a non-object in F:\\Softwares\\php\\htdocs\\samples\\function_26.php on line 20

Thank you in advance

---------------------------------
Now you can chat without downloading messenger. Click here to know how.

[Non-text portions of this message have been removed]





---------------------------------
Never miss a thing. Make Yahoo your homepage.

[Non-text portions of this message have been removed]



                         

       
---------------------------------
 Explore your hobbies and interests. Click here to begin.

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux