mat_seth Posted May 5, 2007 Share Posted May 5, 2007 Hello guys I have problem with my coding. i dunno what is the error but it don't print the output only the name of the file please someone help below is the code <?php $url = $_GET['url']; $scripts = array( "Select2a.php", "Select2b.php"); for ($p=0; $p<count($scripts); $p++) { $fh[$p] = popen("/VertrigoServ/www". "/home/yoursite/public_html/" . $scripts[$p] ." " . $url,"r"); } for ($p=0; $p<count($scripts); $p++) { $st = fgets($fh[$p]); $rs .= $scripts[$p] . " : " . $st ."<br />"; } print $rs; ?> this the code on the process page select2a and it also the same code for select2b [sql]<?php require_once('Connections/server2.php'); ?> <?php $url = $argv[1]; mysql_select_db($database_server2, $server2); $query_Recordset1 = "SELECT * FROM student WHERE stud_id = 20"; $Recordset1 = mysql_query($query_Recordset1, $server2) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_free_result($Recordset1); print $row_Recordset1['stud_id']." ".$row_Recordset1['stud_nama']." ".$row_Recordset1['stud_cos']."<br>"; ?>[/sql] hopefully some one can help Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/ Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 $fh[$p] = popen("/VertrigoServ/www". "/home/yoursite/public_html/" . $scripts[$p] ." " . $url,"r"); will fail as its not a valid path (mainly due to the space) try $fh[$p] = popen("/VertrigoServ/www/home/yoursite/public_html/".$scripts[$p],"r"); Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246075 Share on other sites More sharing options...
mat_seth Posted May 5, 2007 Author Share Posted May 5, 2007 ok i have change like you propose but still the same it only print out name of the file without the value. It look like it don't return the value to the main page Select2a.php: Select2b.php: Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246087 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 ok try this simpler example, get this to work first. $test = open("/VertrigoServ/www/home/yoursite/public_html/Select2a.php","r"); $result = fgets($test, 4096); echo $resultl what exactly are you trying to do ? test #2 echo file_get_contents("/VertrigoServ/www/home/yoursite/public_html/Select2a.php"); Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246093 Share on other sites More sharing options...
mat_seth Posted May 5, 2007 Author Share Posted May 5, 2007 Okay what i want to do is to execute multiple file at the same time like doing forking or multithread in php but this forking and multithread is not supported in window xp platform so i try this coding so that i can execute multiple query at the same time. for $test = open("/VertrigoServ/www/home/yoursite/public_html/Select2a.php","r"); i have change to $test = open("/VertrigoServ/www/johor/Select2a.php","r"); I have try the code and this error occur for no 1 Fatal error: Call to undefined function open() in C:\Program Files\VertrigoServ\www\johor\main.php on line 3 then for no 2 test this error occur Warning: file_get_contents(/VertrigoServ/www/johor/Select2a.php) [function.file-get-contents]: failed to open stream: No such file or directory in C:\Program Files\VertrigoServ\www\johor\main.php on line 3 it suppose to display the data student id = 1 student name = Jack student status = single Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246120 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 it suppose to display the data student id = 1 student name = Jack student status = single if you want to display the parsed data then just use include("/Select2a.php"); i have no idea why your trying this as the performance increase would be less than the extra memory used! the problem is your path is incorrect. fix that and all will be ok Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246170 Share on other sites More sharing options...
mat_seth Posted May 5, 2007 Author Share Posted May 5, 2007 Ok i just want to try new code it is for my project to do a research either this programming can decrease time it fetch the data from the database or not. i have done the include("/Select2a.php"); in the first code so i want to try do multithread or forking in my project but it is not supported because i using win xp. So this programming is one way that it can execute more than one query simultaneously but now it is not working. is there any solution to execute more than one query simultaneously?? For the path i using bundle installer Vertrigo so the path of the program is here C:\Program Files\VertrigoServ\www and for the site that i been doing is C:\Program Files\VertrigoServ\www\johor Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246233 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 So this programming is one way that it can execute more than one query simultaneously but now it is not working. No it won't, it will just process the script directly via php and then return the results to the webserver, anyways good luck with your search MadTechie Out! Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246239 Share on other sites More sharing options...
mat_seth Posted May 6, 2007 Author Share Posted May 6, 2007 Ok but can anyone help me how to return value from the page select2a.php to the page main.php. And using php code if not same like i using that's ok Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246504 Share on other sites More sharing options...
MadTechie Posted May 6, 2007 Share Posted May 6, 2007 if you want to display the parsed data then just use include("/Select2a.php"); Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246510 Share on other sites More sharing options...
Barand Posted May 6, 2007 Share Posted May 6, 2007 you could use AJAX :: s1.php :: <?php echo "HELLO WORLD " ; ?> :: s2.php :: <?php echo date('jS M H:i:s') ; ?> :: mainpage.php :: <html> <head> <meta name="generator" content="PhpED Version 4.5 (Build 4513)"> <title>Sample</title> <meta name="author" content="Barand"> <script> function getXmlObj() { //---------------------------------- // Create xmlhttp request object //---------------------------------- var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } //----------------------------------------------------------- // Message handler // - Sends message to script and waits for completion // - On completion, updates page with script output //----------------------------------------------------------- // url = url to call server-side script // resultID = ID of DIV or SPAN element to receive the output //----------------------------------------------------------- function handleMessages (url, resultID) { //alert(url); var xmlhttp = getXmlObj(); var obj; xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { obj = document.getElementById(resultID); obj.innerHTML = xmlhttp.responseText; } } xmlhttp.send(0); return 0; } function getvals() { var url1 = "s1.php"; var url2 = "s2.php"; handleMessages(url1, "a"); handleMessages(url2, "b"); } </script> </head> <body> <input type="button" name="action" value="Get 2 values" onclick='getvals()'> <br><br> Value 1 is <span id='a' style='color:red'> x<!-- placeholder for value 1 --> </span> and value 2 is <span id='b' style='color:blue'> y<!-- placeholder for value 1 --> </span> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246515 Share on other sites More sharing options...
mat_seth Posted May 6, 2007 Author Share Posted May 6, 2007 Ok thank you MadTechie but the real code is include("Select2a.php"); without / ok if i use if else statement with && to execute two file can it execute simultaneously Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246517 Share on other sites More sharing options...
MadTechie Posted May 6, 2007 Share Posted May 6, 2007 i have to ask but what are you trying to do? if your trying to execute two file can it execute simultaneously, then your going to be searching for a long time, maybe Zend Optimizer would be the way to go! Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246522 Share on other sites More sharing options...
mat_seth Posted May 6, 2007 Author Share Posted May 6, 2007 Still doing research if can do multithread in php in window platform or doing the code that can perform similar to multithread. Zend Optimizer is open source or pay software to download?? Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-246536 Share on other sites More sharing options...
mat_seth Posted May 7, 2007 Author Share Posted May 7, 2007 Hello i have problem here my search code has two database if i put data from server 1 it print the output but if i put the data from server2 it print blank <?php require_once('Connections/server2.php'); ?> <?php require_once('Connections/server1.php'); ?> <?php $time = microtime(); $time = explode(" ", $time); $time = $time[1] + $time[0]; $start = $time; ?> <form name="formsearch" method="post" action="select1.php"><br> <table border=0 width=500 cellpadding=0 cellspacing=0 align=center> <tr> <td width="150" bgcolor="CEE7FF" class="content"><b>Search Student ID</b></td> <td width="250" bgcolor="CEE7FF"><input type="text" name="search" size="35"></td> <td width="100" bgcolor="CEE7FF"><input type="submit" name="submit" value="Search"></td> </tr> </table> </form> <?php $search = $_POST['search']; if($search !=''){ $search = explode(" ", $search); $notext = count($search); mysql_select_db($database_server1, $server1); mysql_select_db($database_server2, $server2); for($i=0; $i<$notext; $i++){ $querysearch1 = "SELECT * FROM pelajar WHERE stud_id LIKE '$search[$i]'"; $resultsearch1 = mysql_query($querysearch1, $server1) or die(mysql_error()); $rowsearch1 = mysql_num_rows($resultsearch1); $querysearch2 = "SELECT * FROM pelajar WHERE stud_id LIKE '$search[$i]'"; $resultsearch2 = mysql_query($querysearch2, $server2) or die(mysql_error()); $rowsearch2 = mysql_num_rows($resultsearch2); //if($rowsearch>0 && $rowsearch2>0){ //while($resultview1 = mysql_fetch_array($resultsearch1) && $resultview2 = mysql_fetch_array($resultsearch2)){ if($resultsearch1 !=null){ $resultview1 = mysql_fetch_array($resultsearch1); $idref1=$resultview1[stud_id]; $name1=$resultview1[stud_nama]; $studencos1=$resultview1[stud_cos]; echo "<table border=0 width=505 cellpadding=0 cellspacing=2 align=center> <tr><td colspan=5 class=content color=#CEE7FF align=left><font color=black><b>Student ID </b></font><font color=#000099> </font><font color=black>:</font></td> <td bgcolor=#99CCFF width=50 align=center>$idref1 </td> <td bgcolor=#99CCFF width=200 align=center>$name1</td> <td bgcolor=#99CCFF width=100 align=center>$studencos1</td>"; } else { $resultview2 = mysql_fetch_array($resultsearch2); $idref2=$resultview2[stud_id]; $name2=$resultview2[stud_nama]; $studencos2=$resultview2[stud_cos]; echo $resultview2; echo "<table border=0 width=505 cellpadding=0 cellspacing=2 align=center> <tr><td colspan=5 class=content color=#CEE7FF align=left><font color=black><b>Student ID </b></font><font color=#000099> </font><font color=black>:</font></td> <td bgcolor=#99CCFF width=50 align=center>$idref2 </td> <td bgcolor=#99CCFF width=200 align=center>$name2</td> <td bgcolor=#99CCFF width=100 align=center>$studencos2</td>"; } }//end while }//end for echo "</table>"; echo "</table>"; //}//end if textgen $time = microtime(); $time = explode(" ", $time); $time = $time[1] + $time[0]; $finish = $time; $totaltime = ($finish - $start); printf ("<br><center><strong> This page took %f seconds to load.</strong></center><br>", $totaltime); ?> Please help needed here thank you Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-247327 Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Share Posted May 7, 2007 and the error is....? EDIT: NM, i give, i'm out Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-247353 Share on other sites More sharing options...
mat_seth Posted May 7, 2007 Author Share Posted May 7, 2007 ok the error if i enter data the student id and the data is in the server 1 it will print the output correctly but if i enter data student id that in the server two it will not print out anything just blank Quote Link to comment https://forums.phpfreaks.com/topic/50118-help-needed-please/#findComment-247360 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.