- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 29
- Posts with Upvotes
- 24
- Upvoting Members
- 21
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 3
Re: I think this would work reasonably fast: [CODE]<?php $filename = "/path/to/file.txt"; $handle = fopen($filename,"r"); if ($handle === false) { exit; } $word = ""; while (false !== ($letter = fgetc($handle))) { if ($letter == ' ') { $results[$word]++; $word = ""; } else { $word .= $letter; } } fclose($handle); … | |
Re: You want this: [CODE]<input type="image" src="blah.png">[/CODE] | |
| Re: My approach would be to create not so much as a database but just a flat file, say tab delimited. You can read the entire thing into memory with PHP and manipulate the data as needed. You could either run a web server locally (Macs have this already built in) … |
Re: The dots get changed to underscores. So use this instead: $linex = $_GET['shapes_image_x']; $liney = $_GET['shapes_image_y']; | |
Re: The Content-Type header must be sent before the Content-Disposition header. | |
Re: Neither of these are the correct approach. strtotime turns the date into an integer. You then subtract one integer from the other which gives you a difference. You are then trying to turn that difference into a date (which will result in a date close to the epoch depending in … | |
Re: Of course. Usually it's in /usr/bin/php Use this syntax: [CODE]/usr/bin/php[I] filename.php[/I][/CODE] | |
Re: Use the $_SESSION array instead. So, for example: [CODE]$_SESSION["name"]="foobar";[/CODE] So now you should not use session_register(), session_unregister() or session_is_registered(). Can you can test using: [CODE]if (isset($_SESSION["name"])) { ... }[/CODE] | |
Re: PHPShadow: [URL="http://www.phpshadow.com"]http://www.phpshadow.com[/URL] This is probably the most cost effective solution because you only need to buy a licence (5 euro) when you encrypt your source code. Once encrypted, your source code will work forever and you don't have to pay them another penny. | |
| Re: [CODE]<?php function find_value($input) { // $input is the word being supplied by the user $handle = @fopen("/users/edwin/list.txt", "r"); if ($handle) { while (!feof($handle)) { $entry_array = explode(":",fgets($handle)); if ($entry_array[0] == $input) { return $entry_array[1]; } } fclose($handle); } return NULL; } ?>[/CODE] |
Re: You're only opening the file. You're not outputting it. Try changing [CODE]$file=fopen("welcome.txt","r");[/CODE] to [CODE]readfile("welcome.txt");[/CODE] | |
Re: PHPshadow ([url]http://www.phpshadow.com[/url]) encrypts PHP code, and requires a license code (a file) to be copied onto the server before it will work. One option is a 50 Euro one-off payment per customer (it's locked to a specific domain name). The other option is an annual payment of 20 Euro. Because … | |
Re: I presume you're using PuTTY to initiate an SSH connection. If so, try the editors [B]nano[/B] or [B]pico[/B] e.g. nano index.php | |
Re: Are you sure you have the [URL="http://www.php.net/manual/en/book.sockets.php"]sockets module[/URL] installed in your PHP installation? Check by looking at the output of phpinfo() | |
Re: Just elaborating on twiss's post: [CODE=HTML]<script type="text/javascript"> function doSomething(elem) { alert ('The ID of the element which triggered this is: ' + elem.id; } </script> <div id="blah" onClick="doSomething(this)">Blah blah blah</div>[/CODE] | |
| |
Re: [QUOTE=tnjiric;1607096][CODE]echo substr($search,0,4); //this would print out "Hello"[/CODE][/QUOTE] Not quite. That would print out "Hell" (4 characters) | |
Re: I agree with evstevemd. [CODE]foreach ($array as $key => $value) { echo 'The key is '.$key.' and the value is '.$value; }[/CODE] $key and $value are created as part of the foreach statement. | |
Re: You can use cron to call a php page. IN your crontab file, the command part would be something like this: [CODE=shell]/usr/bin/php /users/me/www/myfile.php[/CODE] | |
Re: [QUOTE=Shantanu88d;1588131]ok but, in case when we have an entire text file containing thousands of words, what approach can we take ?[/QUOTE] See here: [url]http://www.daniweb.com/web-development/php/threads/369522[/url] | |
Re: [CODE]<?php $text = "one\ntwo\nthree\nfour"; echo preg_replace("/\\n/m"," \n",$text); ?> [/CODE] | |
Re: This page does the calculation. It uses DateInterval so requires PHP 5.3.0 or later. [CODE]<?php $age = $_GET["age"]; $year = $_GET["year"]; $month = $_GET["month"]; $day = $_GET["day"]; if (!$_GET["age"]) { } elseif (!checkdate($month,$day,$year)) { echo "Invalid Date"; } else { $one_year = new DateInterval("P1Y"); $one_day = new DateInterval("P1D"); $age_years = … | |
Re: Here I'm assuming you will be executing the code as the user logs in. So you can do this: [CODE]$random_hour = randbetween(0,23); $current_hour = date("G",time()); if ($current_hour == $random_hour) { // something great happens }[/CODE] If you're trying to implement it on a weekly cycle (i.e. choosing a random hour … | |
Re: It's easier to troubleshoot if you arrange your code neatly, like this:[CODE=php]<?php if (empty($mobile)) { echo '<script language="javascript">alert("Enter Phone Number")</script>;'; } elseif (!(empty($mobile))) { if ((is_numeric($mobile))) { if ((strlen($mobile)!=10)) echo '<script language="javascript">alert("phone number should be of 10 digit")</script>;'; } else { echo '<script language="javascript">alert("Please Enter valid phone number")</script>;'; } } … | |
Re: Look at line 21 of your code:[CODE]echo '</div>' [/CODE] You are missing the semi-colon at the end of the line, i.e. like this:[CODE]echo '</div>;' [/CODE] | |
Re: You cannot have multiple tags with the same id. Your code will output multiple instances of <input id="rate"> and <input id="qty">. You should serialise them, like this: [CODE]<?php include("config.php"); ?> <script type=text/javascript> function multiply(id){ var a; var b; var c; a = document.getElementById("rate" + id).value; b = document.getElementById("qty" + id).value; … | |
Re: This code does what you've asked, and starts looking from "tomorrow". [CODE]<?php $dt = new DateTime("tomorrow",new DateTimeZone("Pacific/Auckland")); $di = new DateInterval("P1D"); while ( ($dt -> format("l") != 'Tuesday') && ($dt -> format("l") != 'Saturday') ) { $dt -> add($di); } echo 'Next sale: '.$dt->format("l, j F Y"); ?>[/CODE] Just replace … | |
Re: AlmostBob's URL to the PHP site is fine, but his description is a bit off. Slashes and spaces are fine. It's nothing to do with the character set but in fact to do with characters reserved for HTML code. Imagine, for example that PHP_SELF contained a greater-than symbol like this: … | |
Re: Is your site one that people have to "sign in" to? If so, why not just build the consent into the standard terms and conditions that one must agree to in order to create an account? If it's a public site and does not require users to sign in, it's … | |
Re: If I can just chime in here.... Might just want to add a space after [B]Location:[/B] |