Jump to content

Recommended Posts

i have a php-cli script that worked fine on a windows platform except it was slow, so i've move the script to a linux platform and replace this part :

 

while (true)

{

			$read[0]=$sock;



			$ready=socket_select($read,$write=null,$error=null,1);



			if (1==$ready)

			{



			citire($sock,$conexiune);



			}

			else 

			{



			deleteOrders($sock,$conexiune); //stergere ordine

			scriere($sock,$conexiune);    //adaugare ordine

			}



}

with this one

 

$pid=pcntl_fork();
if ($pid==-1) 
{
die("could not fork");
}
else if ($pid)
{
while (true)
{
citire($sock,$conexiune);
}
}
else
{
while (true)
{
usleep(200000);
echo "--scriu--";
deleteOrders($sock,$conexiune); //stergere ordine

scriere($sock,$conexiune);    //adaugare ordine
}
}

 

they do the same thing except that now there are two execution wire insted of one;

 

this workes very well, but in my code i have a mysql conection object, that contains some methods:

select, update;

 

in the windows platform those methods were called by only one wire of program ;

 

 

somethimes i get an error that looks like this: when the both of those wire acces same method from that class in the same time some values from the first one pass to the second one.

 

 

<?xml version='1.0'?><bmfm t='112'>

        <info><label>503</label><value>DEOLT</value></info>

        <info><label>504</label><value>MAR09</value></info>

        <info><label>510</label><value>0</value></info>

        <info><label>511</label><value>0</value></info>

        <info><label>525</label><value>0</value></info>

        <info><label>505</label><value>0.416</value></info>

        <info><label>520</label><value>0</value></info>

        <info><label>530</label><value>0</value></info>

        <info><label>531</label><value>0.0</value></info>

        <info><label>500</label><value>Active</value></info>

        <info><label>540</label><value>0</value></info>

        <info><label>550</label><value>0</value></info>

        <info><label>542</label><value>0</value></info>

</bmfm>

 

array(1) {

  [0]=>

  array(2) {

    [0]=>

    string(5) "DEOLT"

    ["contract"]=>

    string(5) "DEOLT"

  }

}

1s

--scriu--\

 

 

PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /root/Desktop/api sibex/db.php on line 43

PHP Warning:  mysql_free_result(): supplied argument is not a valid MySQL result resource in /root/Desktop/api sibex/db.php on line 46

 

Link to comment
https://forums.phpfreaks.com/topic/130855-mysql-error/
Share on other sites

here are the codes from that class, i've tryed to make two difent functions for each wire one, still geting same error,

it is posible that mysql to send same result even if there are diferent querys?

 

function select($query)

{

	$result = mysql_query($query, $this->link)

	or die("Query failed on select : <br>\n ".$this->sql_highlighter($query)." <br>\n".mysql_error());

	$count=0;



	while($line = mysql_fetch_array($result)) {

		$res[$count++]=$line;

	}

	mysql_free_result($result);



	if(isset($res)) return $res;

}


function selectwrite($query)

{

	$result = mysql_query($query, $this->link)

	or die("Query failed on select : <br>\n ".$this->sql_highlighter($query)." <br>\n".mysql_error());

	$count=0;



	while($line = mysql_fetch_assoc($result)) {

		$res[$count++]=$line;

	}

	mysql_free_result($result);



	if(isset($res)) return $res;

}

Link to comment
https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679165
Share on other sites

query executed on first wire:

if (!$sel=$conexiune->select("select `serialM` from ordine where `serialM`='$serialM'"))

die(mysql_error());

echo ".I...".$sel[0][0]."||||";;

 

 

 

query executed on the second wire:

 

if (!$cerereCount=mysql_query("SELECT count(`done`) FROM `ordine_cl` WHERE `done`='nu'"))

die(mysql_error());

 

$x=mysql_fetch_array($cerereCount);

echo "....II...".$x[0]."|||";

 

 

 

somehow the result are reverted between those two wired

 

 

 

<?xml version='1.0'?><bmfm t='114'>

        <info><label>601</label><value>3605704</value></info>

        <info><label>503</label><value>DETLV</value></info>

        <info><label>504</label><value>SEP08</value></info>

        <info><label>420</label><value>*</value></info>

        <info><label>421</label><value>*</value></info>

        <info><label>542</label><value>12</value></info>

        <info><label>410</label><value>0.405</value></info>

        <info><label>415</label><value>GTK</value></info>

        <info><label>412</label><value>Limit</value></info>

        <info><label>411</label><value>0</value></info>

</bmfm>.I...0||||....II...3605704|||<?xml version='1.0'?><bmfm t='114'>

        <info><label>601</label><value>3641540</value></info>

        <info><label>503</label><value>DEBRK</value></info>

        <info><label>504</label><value>DEC08</value></info>

        <info><label>420</label><value>31</value></info>

        <info><label>421</label><value>310474</value></info>

        <info><label>542</label><value>5</value></info>

        <info><label>410</label><value>0.7</value></info>

        <info><label>415</label><value>GTK</value></info>

        <info><label>412</label><value>Limit</value></info>

        <info><label>411</label><value>0</value></info>

</bmfm>Query failed on select : <br>

<b><i>Error</i></b> <i>file</i> "./SQL.sintax" <i>not found.</i> <br>

MySQL server has gone away[root@localhost api sibex v.1.0.2]#

 

Link to comment
https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679188
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.