My PHP page is stuck or stops in the middle
Posted: Tue Jul 14, 2009 2:12 pm
Hi guys,
I'm trying to solve my problem and don't find any solution.
THE PROBLEM IS: I wrote a PHP file on APACHE server that have make some queries.
I added also a log file, and I saw that it's getting stuck or stopped in different places.
I made sure that the code is fine without any endless loops or something like that. All the queries are short and valid.
The DB is very small.
I turned on the error flag (error_reporting(E_ALL);) and the code is clean.
One more thing: I am using post, and it might contain 100 variables.
What is the cause for that?
Thanks!
The CODE is here:
I'm trying to solve my problem and don't find any solution.
THE PROBLEM IS: I wrote a PHP file on APACHE server that have make some queries.
I added also a log file, and I saw that it's getting stuck or stopped in different places.
I made sure that the code is fine without any endless loops or something like that. All the queries are short and valid.
The DB is very small.
I turned on the error flag (error_reporting(E_ALL);) and the code is clean.
One more thing: I am using post, and it might contain 100 variables.
What is the cause for that?
Thanks!
The CODE is here:
Code: Select all
<?php
include("log.php");
error_reporting(E_ALL);
set_time_limit(0);
$log= fopen("update_log_" . date("MjY") . ".txt", "a");
set_log_print();
function shutdown()
{
add_to_log($log, "BYE");
}
$con = mysql_connect("localhost","user","pwd");
if (!$con)
{
die("err: no permission");
}
$db_list = mysql_list_dbs($con);
$db_selected = mysql_select_db("db", $con);
if (!$db_selected)
{
die ("err: db does not exist");
}
$num= $_GET["num"];
printf("num_of_trades=" . $num_of_trades);
if($num==0)
{
$sql= "SELECT QUERY";
printf($sql);
$result = mysql_query($sql,$con);
}
else
{
for($i= 0; $i<$num; $i++)
{
if('' != $_GET["t" . $i])
{
$sql = "SELECT query";
printf("before " . $sql);
$result = mysql_query($sql,$con);
printf("sql=" . $sql . " ans=" . mysql_num_rows($result));
if(mysql_num_rows($result)>0)
{
$sql= "UPDATE QUERY";
printf($sql);
$result = mysql_query($sql,$con);
printf("X_" . $i);
}
else // insert the new order
{
$sql= "Insert QUERY";
printf($sql);
$result = mysql_query($sql,$con);
$sql= "select QUERY";
printf($sql);
$result = mysql_query($sql,$con);
printf("Y");
while($row = mysql_fetch_array($result))
{
$sql= "Insert QUERY";
printf($sql);
$result1= mysql_query($sql,$con);
printf("Z");
}
}
printf("A");
}
}
printf("B");
if($i>0)
{
$sql= "UPDATE QUERY";
printf($sql);
$result = mysql_query($sql,$con);
printf("rows=" . mysql_affected_rows() . ",sql=" . $sql);
}
}
echo "OK";
close_log($log);
mysql_close($con);
?>