...

View Full Version : Two simple questions



Dalziel
04-19-2003, 01:37 AM
:rolleyes:

Firstly, can anyone tell me how to do this in PHP:

if (user's resolution is > 800 X 600)
{
does this
}
else
{
do that
}

Secondly, I've got a counter script, I want to change it so instead of writing a file to the current directory it writes it to a subdirectory called counters, here is the script:



<?php
$filename = current(explode('.', basename($PHP_SELF)));
$fp = fopen("$filename.txt", "r");
$count = fgets($fp, 1024);
fclose($fp);
$fw = fopen("$filename.txt", "w");
$cnew = $count + 1;
$countnew = fputs($fw, $count + 1);
fclose($fw);
?>

Jason
04-19-2003, 02:20 AM
you can't do that in PHP, you need JavaScript to look at the users screen, PHP is a server side language and thus would not be able to do that. So ask in the JS forum. As far as the filename thing with the counter...try changing all instances of $filename.txt to $counter/filename.txt and see if that works. But I really don't know for that one, never tried to do that.


Jason

Dalziel
04-20-2003, 05:13 PM
Originally posted by Jason
you can't do that in PHP, you need JavaScript to look at the users screen, PHP is a server side language and thus would not be able to do that. So ask in the JS forum. As far as the filename thing with the counter...try changing all instances of $filename.txt to $counter/filename.txt and see if that works. But I really don't know for that one, never tried to do that.


Jason

$counters/filename.txt???

Shouldn't it be counters/$filename.txt since the counters directory is not part of the variable.

Phantom
04-20-2003, 07:01 PM
$filename.txt? Shouldn't it be $filename, and have the variable contain something like "counted.txt"?

But yes, it would be counter/$filename

Dalziel
04-22-2003, 05:14 PM
$filename is the name of the file (e.g. if the script is in index.php $filename is set as index) I did this so I could add the script to multiple pages without editing it.

missing-score
04-22-2003, 06:08 PM
Although you cannot sense resolution with PHP, you can get a similar effect by mixing JS and PHP:

Get the resolution, insert it into a hidden form, have the form submitted on the clicking of a link.

You may not get this, I hope you do tho. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum