Jump to content
xisto Community

Spectre

Members
  • Content Count

    1,034
  • Joined

  • Last visited

Everything posted by Spectre

  1. Little off-topic, but Xisto's method could be repeated using Apache's mod_rewrite (I'm not 100% sure what path Xisto takes, but I'm assuming it would similar to this): RewriteRule ^/?forums/(.*)-t([0-9]*)\.html$ /path/script.php?tid=$2 [L,QSA] This completely disregards the actual path, only taking into consideration the numbers which appear after the '-t' and before the '.html', and passing that value onto '/path/script.php' which can then do with it as it will. This URL rewriting is done on Xisto purely for SEO purposes; there are many other things you could use it for, though.
  2. The way most such systems work is simply by storing a timestamp of the user's last activity in the database, and when they have been inactive for a certain amount time - say, 20 minutes - just assuming they are offline. There is no universally reliable method of actually knowing when they are currently looking at your site. You could take it a step further and have all pages automatically refresh at certain intervals, so as to ensure they remain active. Quick example: $timestamp = time() - (20*60); // Where 20 = minutes.@mysql_query('UPDATE user_table SET user_online_field = 0 WHERE user_last_active_field <= ' . $timestamp);
  3. *Sigh. I won't even bother with that one. You just stay in your little world. Anyway, .hack//GU, I would appreciate it if you could please make your descriptions a little clearer and take the time to consider which forum to place your questions in in the future. I don't know why I would have assumed you wanted to use PHP to do the actual printing after posting this in the PHP forum... how stupid of me, right elrohir?
  4. Assuming I understand your problem correctly, you can either specify the script in the 'action' value of the form (eg. '<form action="/target_script.php" method="post">), or include() the script from the page that you have the form submit data to. The $_POST variable is an 'autoglobal', meaning that any section of any script has access to it. So if, for example, you use include('other_script.php'); from within target_script.php, then other_script.php will have full access to the $_POST variable. If that makes sense...
  5. I respect your opinion, but I think you're on the wrong track entirely. There is absolutely no point in outputting a JavaScript statement when trying to print via PHP. What you're saying isn't wrong, per se - it is simply out of context and solves little. If .hack//GU wanted to use JavaScript, I'm sure he would have specified it, but instead he has asked how to use PHP to print. Not use PHP to send JavaScript to a client which can then be dealt with. I'd rather not argue about this until further clarification from .hack//GU.
  6. Hmm... I think you're a little confused. Assuming your MySQL host and web host share the one server (or at least, are on the one local network), it won't use any bandwidth no matter how many queries you execute, because the traffic never leaves the network and therefore is not counted. It's not until you start sending data to a user from your server that it will start to eat away at the bandwidth. You can have as many queries as you like in a script. The only real limitation you may face is speed - if you attempt to execute a large number of complex SQL queries in one go, the server may take a while to process them and begin to slow down, particularly if you have very large databases. This may present something of a problem if your script carries out a lot of queries. The only related problem I can think of is the number of connections a single MySQL host can handle at any one time. This is particularly a problem on shared webhosts that host thousands and thousands of different sites, all of which could be attempting to access a single MySQL host at any given time (some long-term members of Xisto may have seen this issue raised before). Poor coding practises can also lead to trouble, such as failing to clear query memory, close connections, etc.
  7. With all due respect - and I do mean that - do you actually know what you're talking about? This: <?phpecho '<a href="java script:window.print()">Print</a>';?> Will produce the exact same result as simply placing: <a href="java script:window.print()">Print</a> Somewhere in the HTML. All your code is doing is outputting the text. It doesn't use PHP to print at all. Just JavaScript. No PHP. JavaScript only. PHP is not being used. JavaScript is. PHP does nothing here. JavaScript does everything. Outputing code as text does not cause it to be executed in any form; you cannot combine JavaScript and PHP to operate together at a server-level as JavaScript is client-side, and only operates from within the user's browser (if it supports JavaScript, of course). Just to re-iterate: what you are suggesting does not use PHP at all. [edit] For some reason (security?), the IPB code parser is insisting that 'javascript' become 'java script'. There should not be a space in the link.
  8. Ok, now let's review what that does: causes the script to output a simple JavaScript statement in plaintext which the visitor's browser will then interpret as it will, which is exactly the same as adding it in the HTML. It isn't going to execute anything at the server's end, and solves little. I think one (or more?) of us is misunderstanding .hack//GU's problem here. I'm assuming he wants to send output to the printer at the server, not the client. JavaScript has no control over the server whatsoever. All the window.print() function will do is cause the browser the visitor is using (assuming it supports JavaScript) to print the current webpage, with nothing happening at the server's end whatsoever. I don't know why you would want to use PHP to print anything in the first place, but as .hack//GU posted it in the PHP programming forum, I'm assuming that is what he is after.
  9. The example in the print() command reference calls a COM event to trigger the printing, which is similar to how JavaScript operates - however, PHP is server-side, JavaScript is not. I don't think .hack//GU simply wants to print the current page rendered by the browser.
  10. Take a look at the Printer Functions reference. These apparently only work on certain versions of Windows, and require additional PECL extensions (I have not tested any of these functions, and therefore cannot really comment). There's an example on the print() function listing for sending output to a printer (note that the print() function simply displays output), apparently taken from Tufat.com. This example is also on Windows, and at a glance, appears to utilize Acrobat Reader, Microsoft Word or Microsoft Excel to do the actual printing.
  11. There is a function in PHP5 str_split() which allows you to split a string into an array. In earlier versions, jlhaslip's suggestion would work fine, but here is a possibly more useful method which emulates the str_split() function: if( !function_exists('str_split') ) { function str_split( $string, $split_length = 1 ) { if( $split_length < 1 || !is_numeric($split_length) ) { trigger_error('str_split(): The length of each segment must be greater than zero',E_USER_WARNING); return false; } $split_array = array(); for( $i=0;$i<strlen($string); ) { $split_string = substr($string,$i,$split_length); $i += strlen($split_string); $split_array[] = $split_string; } return $split_array; }}
  12. It is the forward slash causing the problem. It's saying that it encountered an unexpected '=' symbol because it simply treating the slash as an operation of division - ie. divide the variable $Problem by the constant Query, which is perfectly legal in PHP (assuming, of course, the constant 'Query' has been defined). Because this is all perfectly ok, and PHP is assuming that you aren't trying to name the variable with a slash in it, it is unable to continue past the equals symbol as you obviously cannot assign a value to a dynamic equation, which is what it thinks '$Problem/Query' is. Just remove the slash. Replace it with an underscore, or simply use '$ProblemQuery'. Then replace all instances of it within the script. This has already been mentioned in this thread...
  13. I would recommend you learn how to do it rather than simply have someone show you. All the same, here is a quick example: $result = mysql_query('SELECT COUNT(*) FROM table_name');$array = mysql_fetch_array($result);echo $array[0];
  14. Try something like this. It's not perfect, and I only wrote and tested it very quickly, but it's a start: <table width="100%"><tr><td width="90%"><strong>File</strong></td><td width="10%"><strong>Last Modified</strong></td></tr><?php$files = array();$directories = array('.');for( $i=0;$i<count($directories);$i++ ) { $path = $directories[$i]; $directory = opendir($path); while( $contents = readdir($directory) ) { if( $contents != '.' && $contents != '..' ) { $item = $path . '/' . $contents; if( is_dir($item) && !in_array($item, $directories) ) { $directories[] = $item; } else { // // Note that if you wanted to sort the files by the time // they were created rather than modified, you would use // the function filectime() rather than filemtime() here. // $filetime = filemtime($item); while( isset($files[$filetime]) ) { $filetime++; } $files[$filetime] = $item; } } } closedir($directory);}krsort($files);$files_k = array_keys($files);for( $i=0;$i<count($files);$i++ ) { echo '<tr>' . "\n"; $filetime = $files_k[$i]; $file = $files[$filetime]; echo '<td style="font-size:10px;">' . $file . '</td>' . "\n"; echo '<td style="font-size:10px;">' . date('d-M-Y H:i', $filetime) . '</td>' . "\n"; echo '</tr>' . "\n";}?></table>
  15. Heh. The humor of programmers. Anyway, ASP and PHP can run on the same machine (as Inspiron has obviously pointed out); however, I would not personally recommend it. PHP runs optimally on Apache, and ASP on IIS; whilst both can run with either webserver, you will almost certainly encounter some problems. On the few occasions I have had to work in PHP on an IIS server, I have had to write and rewrite code time and time again to get it to work, whereas it would work flawlessly on Apache (I don't use an IIS server myself, but some of the people I've done PHP work for have). So anyway, I think it would be better to pick an environment and stick with it - either IIS on Windows with ASP, or Apache on Linux with PHP.
  16. Try something like: ini_set('session.use_only_cookies',0); Before session_start(). You could find out more by checking out the session reference from PHP.
  17. Unless you explicitly destroy the session (eg. by prematurely calling session_destroy()) or PHP is unable to determine the session's owner, this shouldn't happen. Generally speaking, PHP will either use a cookie to indicate a session's owner or append the session ID to all links within the page (eg. a link to '/page.html' may become '/page.html?PHPSESID={32-byte MD5 hash}'). If it using the second method, perhaps it is losing track of session owners if the link is unable to be modified - are you using irregular HTML or can you think of some other problem that may affect it in this way? Anyway, try setting and/or checking when the session is set to expire with the session_cache_expire() function. It probably wouldn't hurt to further explore PHP sessions either; perhaps it's your server configuration or a problem within your code that you aren't aware of.
  18. Alternatively, you could simply get the contents of the file, and replace the said string with the variable's value, something like: <?php$abc='123';echo str_replace('$abc',$abc,file_get_contents('index.htm'));?> You may want to check out the Smarty template engine; it's very easy to use and works wonderfully, and operates on a similar premises to this. You simply add the variable in the template along the lines of {$VARIABLE}, and Smarty automatically replaces it with the assigned value ($smarty->assign('VARIABLE','value') when displaying it. Anyway, PHP is not going to process any data outside of the <? ?> tags (usually <?php ?>, but not always). Which means that you are going to explicitly instruct it to output the said variable.
  19. I don't think the two are really as comparable as they may seem. They are obviously both scripting languages, but they were designed for two very different purposes. Perl was originally intended only for local use, allowing large jobs to be easily automated through it's scripting power, and was only developed into a CGI for Web use later on. PHP, however, was created with the Web in mind right from the get-go; and in that sense, it may be considered somewhat better for use in such an environment. In my opinion, Perl is more powerful than PHP, but isn't ideally suited for use online; for creating dynamic websites, I think PHP is better.
  20. In MySQL, it depends on the data type. The maximum length of a VARCHAR type, for instance, is specified in the field's creation (eg. field_name VARCHAR(limit)), with an absolute peak of 255 characters in older versions of MySQL (<= 4x, I think). The TEXT type, however, has a much larger limit of 65,535 characters, and chances of a text-based message being that long is slim. There are other data types though; such as LONGTEXT, which has a limit of 4,294,967,295 characters (that's about 3.9-4GB of text).
  21. All of these companies use different languages for different purposes. The search engines do not use the same languages to serve web-based data that they do to crawl sites, for instance. Google, for example, uses Python and C/C++ for their backbone crawling systems; Yahoo! uses a heavily modified version of Apache and, for certain services, PHP for serving webpages. There was some website floating around a while back run by a Yahoo! developer, which outlined at least some of the technologies they are using. It's probably not that hard to find out - although I could be wrong, I doubt they would really guard the basic technology they are using (other than, perhaps, Google, who jealously guard everything).
  22. A simple approach would be to store the message in a database, along with the ID of who it was sent to, and then display it to the recipient the next time they log in. For example, Arthur sends a message to a user called 'Martha'. The script that checks the database for a user called 'Martha', and discovers that her ID is 53. It then stores the message in the database, along with the ID 53. Then once user 53 or 'Martha' logs in again, it simply displays the message on her screen (or informs her that a message has arrived). I wont' write out all the code for you, but it's certainly not difficult to do.
  23. Spectre

    Php Counter

    Of course it's possible (and incredibly simple). Just store an integer value in some form of database (flat file, MySQL, or whatever), and increase it every time a user visits your page. You could get slightly more complex and only count unique visitors using cookies, IP addresses, or both.
  24. That's not entirely true. There are numerous framed sites that are ranked well on Google. One problem is that only the very first page will be indexed under the domain name - any other pages linked to from within the frames should be indexed with their real URL (ie. mypage.uniserve.ca/~insideout/page.html), unless she links to them via the domain name (ie. coachinsideout.com/page.html) and it is set up to allow such forwarding. I wouldn't recommend using a framed site, but if you have no other choice, then don't freak about not being indexed or ranked - it will happen.
  25. How do these old topics keep re-surfacing?Anyway, a frame is a frame. I'm assuming by 'layer' you mean 'table' - as it is contained with the page itself, it doesn't count as a frame.Also, the more 'intelligent' search engines such as Google are able to index framed pages fine. I still wouldn't recommend it (not just for SEO purposes, but because I consider it a bad practice), but it isn't the end of the world if you have frames on your pages.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.