"Flock" function is not working
Moderator: General Moderators
-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
"Flock" function is not working
Hi to all the Guru
I notice when i use the function Flock in php5.1 I was told that i had an error
error is shown as
"Warning: flock() expects parameter 1 to be resource, boolean given in c:\Inetpub\wwwroot\02\processorder.php on line 69"
where by if i use the EasyPHP 1.7 at another virtual Machine. the Flock function is working.
Have i done anything wrong for that?
Thanks in advance for your guidance.
I notice when i use the function Flock in php5.1 I was told that i had an error
error is shown as
"Warning: flock() expects parameter 1 to be resource, boolean given in c:\Inetpub\wwwroot\02\processorder.php on line 69"
where by if i use the EasyPHP 1.7 at another virtual Machine. the Flock function is working.
Have i done anything wrong for that?
Thanks in advance for your guidance.
-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
feyd | Please use
it is working at my WM with Easyphp1.7. not in my VM with Php 5.1
hm...
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]Code: Select all
<?php
// create short variable names
$tireqty = $_POST['tireqty']; // value derived from last page 10
$oilqty = $_POST['oilqty']; // value derived from last page 20
$sparkqty = $_POST['sparkqty']; // value derived from last page 30
$address = $_POST['address']; // Singapore
$date = date('H:i, jS F');
?>
<html>
<body>
<?php
$TotalAmount=$tireqty+$oilqty+$sparkqty; //$TotalAmount=60
echo '<p>Total of order is '.$TotalAmount.'</p>';
echo '<p>Address to ship to is '.$address.'</p>'; // Singapore
$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t".$sparkqty." spark plugs\t\$".$totalamount."\t". $address."\n";
// open file for appending
@ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $outputstring, strlen($outputstring));
flock($fp, LOCK_UN);
fclose($fp);
echo '<p>Order written.</p>';
?>
</body>
</html>hm...
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
yes the register_global is off
but i dun think that is the solution. because i am very sure the coding is working under the Easyphp compiler.
I start to worry whether is my installation process is wrong.
1. Create PHP
2. Set php.ini
3. setting under IIS
4. pear installed
but i still dun get the fopen working. same go to Mail() and ODBC_exec.
I had tried to removed the @ sign. and it still dun work... instead i get another line of error as well.
may i know. do we need to copy some other DLL in order to make the PHP page working beside the standard Ext from php 5.1 zip file?
but i dun think that is the solution. because i am very sure the coding is working under the Easyphp compiler.
I start to worry whether is my installation process is wrong.
1. Create PHP
2. Set php.ini
3. setting under IIS
4. pear installed
but i still dun get the fopen working. same go to Mail() and ODBC_exec.
I had tried to removed the @ sign. and it still dun work... instead i get another line of error as well.
may i know. do we need to copy some other DLL in order to make the PHP page working beside the standard Ext from php 5.1 zip file?
-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
I notice something
in my VM with PHP 5.1
I use the
I dun have the Flock function
where If i use the VM with Easy PHP 1.7
I have the Flock Function
i think it is the extension issue. ... same go to the ODBC_Exec function
in my VM with PHP 5.1
I use the
Code: Select all
<?php
echo 'Function sets supported in this install are:<br />';
$extensions = get_loaded_extensions();
foreach ($extensions as $each_ext)
{
echo "$each_ext <br />";
echo '<ul>';
$ext_funcs = get_extension_funcs($each_ext);
foreach($ext_funcs as $func)
{
echo "<li> $func </li>";
}
echo '</ul>';
}
?>where If i use the VM with Easy PHP 1.7
I have the Flock Function
i think it is the extension issue. ... same go to the ODBC_Exec function
-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
Hi Fyed
Yes I install from scratch. which i bought a book. that taught me to
1. Copy All the DLLs. to C:\windows\
2. Copy php.ini to C:\Windows\
3. amend the C:\php.ini
- Find Extension_dir = C:/php/ext
- doc_root = "c:/inetpub/wwwroot"
- remove the ";" from "extension = php_pdf.dll"
- remove the ";" from "extension = php_gd2.dll, php_imap.dll and php_mysqli.dll"
4. go to my IIS ..
- add in .php in to the home directory
- add php at ISAPI filter.
how do i know which dll are need to be remove the ";". Is there any reference to check
so sorry for troubling u.
Yes I install from scratch. which i bought a book. that taught me to
1. Copy All the DLLs. to C:\windows\
2. Copy php.ini to C:\Windows\
3. amend the C:\php.ini
- Find Extension_dir = C:/php/ext
- doc_root = "c:/inetpub/wwwroot"
- remove the ";" from "extension = php_pdf.dll"
- remove the ";" from "extension = php_gd2.dll, php_imap.dll and php_mysqli.dll"
4. go to my IIS ..
- add in .php in to the home directory
- add php at ISAPI filter.
how do i know which dll are need to be remove the ";". Is there any reference to check
so sorry for troubling u.
Change this line:to this:and see if you receive a different error.
Code: Select all
@ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab');Code: Select all
$fp = fopen(realpath($_SERVER['DOCUMENT_ROOT'] . '/../orders/orders.txt'), 'ab');-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE
run this:
and post the output 
Code: Select all
<?php
var_dump(realpath($_SERVER['DOCUMENT_ROOT'] . '/../orders/orders.txt'));
?>Also always remember flock() in PHP Windows ISAPI will not inherit the system permissions so LOCK_EX and LOCK_SH will just hang your script instead of returning FALSE if a another instance is using that file or folder. It works as it it should only in CGI PHP under windows! If using ISAPI PHP under windows, then create a fake lock to test if a file or folder is in use!
yj!
yj!
-
lawrence_chtan
- Forum Newbie
- Posts: 22
- Joined: Mon Jan 02, 2006 8:20 pm
- Location: SINGAPORE