Jump to content

Help needed please...


mat_seth

Recommended Posts

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 :)

 

Link to comment
Share on other sites

$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");

 

Link to comment
Share on other sites

 

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");

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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

Link to comment
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.