1

In My php code i call stored-procedure before Normal SQL (link : SELECT * FROM TABLE;) Query run. for that stored-procedure run but Normal SQL can-not run. I use mysql_query() in both case. but when i run normal SQL it run both time.

I have a class dataManager that have the mysql_query()

here is my code :

require_once 'DL/DataManager.php'; 
require_once 'utils/Utils.php';
require_once 'DL/class/event/Event.php';
$Utils = new Utils();
$obj = new Event();

$result = array();

$result = $obj->get_all_event_data("NULL"); //Query =  "CALL events_all_data(" . $ID . ");";

echo date("y-m-d h:i:s")."<br />";

echo $Utils->getString_UserName_ByUserID( "23" )."<br />"; // Not Run   Query = SELECT  `USER_NICK` FROM  `USER_INFO` WHERE  `USER_ID` ='".$string ."';";

DataManager.php

public function openConnection()
{
    $this->connection = mysql_connect($this->HostName, $this->UserName, $this->PassWord);
        if (!$this->connection)
        {
                return mysql_error();
        }
        mysql_select_db($this->DataBase);
        return $this->connection;
} 

execute sql query

public function retrieveData($Query = "")
{
    //$Query = mysql_real_escape_string($Query);
    //echo "DB retriveData query : ".$Query. " <br />";
    $data = mysql_query($Query);
    $num_rows = mysql_num_rows($data);
    //echo "db ret number : ".$num_rows." asdas: ". "\n";


    if($num_rows)
    {
        $this->Data = array();
        //$i = 0;
        while ($mat[] = mysql_fetch_row($data));
            //echo $mat[$i++][2]."<br />";
        $this->Data = $mat;
        //print_r($this->Data);
    //$result = $this->getArrayTranspose($mat);
    }
    else
    {
        $this->Data = NULL;
    }

    //return $result;

}

Connection Close

public function closeConnection()
{
    if(!$this->connection)
    {
        mysql_close ();

        return ;
    }
    else if($this->connection == NULL)
    {
        mysql_close ();

        return ;
    }
    else if(!isset($this->connection))
    {
        mysql_close ();

        return ;
    }
    else if(is_resource($this->connection))
    {
        mysql_close($this->connection);
        return ;
    }
    else
    {
        //mysql_close();
    }

}
1
  • which driver are you using for connection mysqli/mysql? Commented Mar 28, 2013 at 0:46

2 Answers 2

1

In your code you did not mention anywhere that what is $string Try to run query like this to get error code.

 $mat=mysql_query($query) or die (mysql_error());

Give it a try.

Sign up to request clarification or add additional context in comments.

1 Comment

mysql_error()give me this Error: Commands out of sync; you can't run this command now
0

Mysql Error is: Commands out of sync; you can't run this command now

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.