Jump to content

Recommended Posts

i have two files in php both have the same code and the file is

<?php
session_start();

$con = mysql_connect("l","root",""); // here localhost and password will be filled accordingly
if (!$con)
{
die('Connection failure: ' . mysql_error());
}

mysql_select_db("student",$con);

$fetch=mysql_query("SELECT * from student1") or die(mysql_error());
$row = mysql_fetch_array($fetch) or die(mysql_error());

sleep(10);

echo "Name: ".$row[0]."</br>";
echo " Age: ".$row[1]."</br>";
echo " Address: ".$row[2];
mysql_close($con);
?>

Now i have another file which has the same code as above except there is no sleep function used in it . Now when i run the file which is wothout sleep it displyas results in seconds however the file with sleep function takes it time.

 

Now the problem is if i load the file woth sleep function first then its delayed nature is reflected in another file which is without sleep() i.e now the file without sleep is taking longer time to open.

 

please explain all this and possible solution to this problem

the other file is

<?php
session_start();

$con = mysql_connect("localhost","root","instablogs");
if (!$con)
{
die('Connection failure: ' . mysql_error());
}

mysql_select_db("student",$con);

$fetch=mysql_query("SELECT * from student1") or die(mysql_error());
$row = mysql_fetch_array($fetch) or die(mysql_error());

echo "Name: ".$row[0]."</br>";
echo " Age: ".$row[1]."</br>";
echo " Address: ".$row[2]."</br>";

mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/213035-sessions-in-php/
Share on other sites

Now i have another file which has the same code as above except there is no sleep function used in it . Now when i run the file which is wothout sleep it displyas results in seconds however the file with sleep function takes it time.

 

Now the problem is if i load the file woth sleep function first then its delayed nature is reflected in another file which is without sleep() i.e now the file without sleep is taking longer time to open.

 

what? I know you didn't just answer your own question... could you elaborate a little more.

Link to comment
https://forums.phpfreaks.com/topic/213035-sessions-in-php/#findComment-1109536
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.