alin19 Posted October 31, 2008 Share Posted October 31, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/ Share on other sites More sharing options...
JonnoTheDev Posted October 31, 2008 Share Posted October 31, 2008 Must be a bad database query. Get your script to die on query error if(!$result = mysql_query("")) { die(mysql_error()); } $row = mysql_fetch_array() Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679158 Share on other sites More sharing options...
alin19 Posted October 31, 2008 Author Share Posted October 31, 2008 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; } Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679165 Share on other sites More sharing options...
JonnoTheDev Posted October 31, 2008 Share Posted October 31, 2008 Print out your query to test. Change the query code to my prev post rather than using 'or die......' Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679178 Share on other sites More sharing options...
alin19 Posted October 31, 2008 Author Share Posted October 31, 2008 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]# Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679188 Share on other sites More sharing options...
alin19 Posted October 31, 2008 Author Share Posted October 31, 2008 hasn't this hapend to anyone? Quote Link to comment https://forums.phpfreaks.com/topic/130855-mysql-error/#findComment-679228 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.