Posts
 
Reputation
Joined
Last Seen
Ranked #434
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
89% Quality Score
Upvotes Received
29
Posts with Upvotes
24
Upvoting Members
21
Downvotes Received
3
Posts with Downvotes
3
Downvoting Members
3
12 Commented Posts
2 Endorsements
Ranked #621
Ranked #505
~69.0K People Reached
Favorite Forums
Favorite Tags

94 Posted Topics

Member Avatar for Shantanu88d

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); …

Member Avatar for edwinhermann
0
577
Member Avatar for branding4you
Member Avatar for ab_omid
0
5K
Member Avatar for stephen_UK

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) …

Member Avatar for stephen_UK
0
170
Member Avatar for statsProf

The dots get changed to underscores. So use this instead: $linex = $_GET['shapes_image_x']; $liney = $_GET['shapes_image_y'];

Member Avatar for statsProf
0
195
Member Avatar for adityamadhira
Member Avatar for adityamadhira
0
142
Member Avatar for garyjuano

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 …

Member Avatar for edwinhermann
0
140
Member Avatar for petrovitch

Of course. Usually it's in /usr/bin/php Use this syntax: [CODE]/usr/bin/php[I] filename.php[/I][/CODE]

Member Avatar for edwinhermann
0
159
Member Avatar for Commando112

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]

Member Avatar for edwinhermann
0
102
Member Avatar for unikorndesigns

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.

Member Avatar for edwinhermann
0
932
Member Avatar for kirtan_thakkar

[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]

Member Avatar for trickist17
0
12K
Member Avatar for bangla

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]

Member Avatar for ddymacek
0
165
Member Avatar for ibrahimbit17

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 …

Member Avatar for ibrahimbit17
0
412
Member Avatar for puvi

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

Member Avatar for edwinhermann
0
78
Member Avatar for knan

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()

Member Avatar for edwinhermann
0
301
Member Avatar for karthik_ppts

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]

Member Avatar for ushajase
0
16K
Member Avatar for phorce
Member Avatar for decade

[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)

Member Avatar for tnjiric
0
138
Member Avatar for Paaat

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.

Member Avatar for edwinhermann
0
116
Member Avatar for palsoft

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]

Member Avatar for palsoft
0
2K
Member Avatar for Shantanu88d

[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]

Member Avatar for edwinhermann
0
3K
Member Avatar for haimz

[CODE]<?php $text = "one\ntwo\nthree\nfour"; echo preg_replace("/\\n/m"," \n",$text); ?> [/CODE]

Member Avatar for edwinhermann
0
98
Member Avatar for paarade

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 = …

Member Avatar for diafol
0
136
Member Avatar for public-image

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 …

Member Avatar for edwinhermann
0
8K
Member Avatar for jacob21

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>;'; } } …

Member Avatar for edwinhermann
0
84
Member Avatar for Spyzker

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]

Member Avatar for diafol
0
179
Member Avatar for rpv_sen

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; …

Member Avatar for edwinhermann
0
195
Member Avatar for verbob

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 …

Member Avatar for verbob
0
153
Member Avatar for Yemen Coder

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: …

Member Avatar for Yemen Coder
0
148
Member Avatar for kained

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 …

Member Avatar for edwinhermann
0
211
Member Avatar for noahshoa2

If I can just chime in here.... Might just want to add a space after [B]Location:[/B]

Member Avatar for twiss
0
214
Member Avatar for amoken

You can still use ErrorDocument in .htaccess to invoke a customised page for Error 403, and then in the custom Error 403 page you put at the top: [CODE]<?php header("HTTP/1.0 404 Not Found",true,404); ?> [/CODE] That will send the correct HTTP 404 response.

Member Avatar for edwinhermann
0
20
Member Avatar for ivan3510
Re: time

Here's how you should be using the Date/Time features in PHP to achieve the same thing: [CODE]<?php $tz = new DateTimeZone('Europe/Paris'); $time = new DateTime("@1303889758",$tz); $time -> setTimeZone($tz); $convert = $time -> format("G:i:s d. n. Y. "); //convert $time to our date: output is 9:35:58 27. 4. 2011. echo $convert."<br>"; …

Member Avatar for ivan3510
0
104
Member Avatar for Moporho

I suspect it's that the setting "short_open_tag" is forced on, and so the first two characters of line 1 (the less-than symbol followed by the question mark) is causing PHP to start interpreting what is after that, which happens to be the contents of the XML header tag and not …

Member Avatar for edwinhermann
0
244
Member Avatar for abhi10kumar

Assuming your [I]allow_url_fopen[/I] setting is enabled (see [url]http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen[/url]) then here's the code: [CODE]<?php file_put_contents("/path/to/filename.html",file_get_contents("http://www.example.com/")); ?>[/CODE]

Member Avatar for edwinhermann
0
76
Member Avatar for cliffcc

Yes, there's always a risk that someone breaks into the server and steals your code. Not only do they now have your IP, but also potentially passwords (to databases) etc. You can encrypt your PHP code so that it's unreadable. Try [url]http://www.phpshadow.com[/url]

Member Avatar for edwinhermann
0
218
Member Avatar for redous

[quote]strong>$session->username</strong> <span style='font-size: 80%;'></span></li>'[/quote] The bit that's wrong is the use of single quotes instead of double quotes in HTML. The "span" tags should read: [CODE=html]<span style="font-size: 80%;"></span>[/CODE]

Member Avatar for redous
0
198
Member Avatar for timpogue

Is the input the entire sentence, or just the name "Tim"? In the case of the latter, and aside from capitalisation, and assuming it's only the asterisk you ever want to replace, then use this: [CODE]$input = "Tim"; $pattern = "Hi my name is *"; $output = str_replace("*",$input,$pattern);[/CODE] Or is …

Member Avatar for edwinhermann
0
142
Member Avatar for ayooshkasmth

[CODE]$low = "Low"; $int = "Intermediate"; $high = "High "; switch($perm) { case $low: echo "Low perm <br>"; break; case $int: echo "Intermediate perm <br>"; break; case $high: echo "High perm <br>"; break; default: echo "No information has been provided. "; }[/CODE]

Member Avatar for ayooshkasmth
0
99
Member Avatar for mpc123

[CODE]$result = mysql_query("SELECT COUNT(*) FROM TEST Where Name LIKE 'Smith%'") or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row[0] ."; }[/CODE]

Member Avatar for edwinhermann
0
100
Member Avatar for canterorist

Use this function: [CODE]function rmdir_recursive($dir) { $files = scandir($dir); foreach ($files as $file) { if ( ($file == ".") || ($file == "..") ) { continue; } $file = $dir . '/' . $file; if (is_dir($file)) { rmdir_recursive($file); rmdir($file); } else { unlink($file); } } rmdir($dir); }[/CODE] Call it like …

Member Avatar for canterorist
0
80
Member Avatar for 1x4n
Member Avatar for harry88

You need to put some debugging lines in to see where it's going back to login.php. There are two instances of header("login.php"). I suggest before each one you write some output (which will also prevent the redirect) so that you can identify which path your script is taking. Also line …

Member Avatar for qualitybrains
0
122
Member Avatar for jhbalaji

IonCube is quite expensive! I would use the function get_included_files() to determine what was included. See [url]http://nz2.php.net/manual/en/function.get-included-files.php[/url] for more information.

Member Avatar for diafol
0
155
Member Avatar for Venom Rush

How about this for a one-liner: [CODE]echo preg_replace_callback('/<a ([^>]+)>([^<]*)<\/a>/m',create_function('$matches','return str_replace(" ","_",$matches[0]);'),$string);[/CODE] [B]BEFORE: [/B] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in ante nec nisl vulputate faucibus at quis <a href="path/to/page" class="pageLink">felis</a>. Aliquam vel dui orci. Integer eget eros sed lorem vestibulum aliquet. Aliquam tortor lorem, semper et rutrum …

Member Avatar for Venom Rush
0
143
Member Avatar for jeeter19

The scope of ordinary variables outside a function remain outside that function. Conversely, the scope of ordinary variables inside a function remain inside that function. In other words, you cannot declare a variable outside a function and use it inside a function, without using the global keyword. So what you …

Member Avatar for diafol
0
104
Member Avatar for D4n1sD

Firstly, I should point out that not all email addresses are of the form something@letters.2-3letters. For example: [email]john@vuw.ac.nz[/email], [email]bob@blah.travel[/email], [email]fred@sprint.mobi[/email], and so on. I recommend you use this logic to determine the validity of an email address: [CODE]if (!preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,})$/',$email)) { echo "Invalid address"; }[/CODE] Obviously you'll need to replace the …

Member Avatar for edwinhermann
0
101
Member Avatar for Encrypted

The only way I can think is like this: [CODE]$sql = "SELECT * FROM something WHERE id LIKE \"%,".$test.",%\" OR id LIKE \"".$test.",%\" OR id LIKE \"%,".$test."\"";[/CODE]

Member Avatar for Encrypted
0
129
Member Avatar for phpsteve

[CODE]$sql = "SELECT COUNT(*) FROM tblName WHERE type=\"minor\""; $result = mysql_query($result); $row = msql_fetch_row($result); $number_of_minor_defects = $row[0]; $sql = "SELECT COUNT(*) FROM tblName WHERE type=\"major\""; $result = mysql_query($result); $row = msql_fetch_row($result); $number_of_major_defects = $row[0]; print "Minor defects: ".$number_of_minor_defects."<br>Major defects: ".$number_of_major_defects;[/CODE] Obviously alter the SQL code to suit your table structure …

Member Avatar for edwinhermann
0
96
Member Avatar for drewpark88

Err, don't think the code Will posted is entirely right. You need: [CODE]substr($_REQUEST['cc_number'] , -4)[/CODE] See [url]http://www.php.net/substr[/url] for more info and examples.

Member Avatar for edwinhermann
0
207
Member Avatar for fatcat2010

[QUOTE=fatcat2010;1164372]hi experts, always curious . why sometimes reference book use simple quotation mark. sometime switch to double quotation mark. Does it matter in php? e.g. define ([COLOR="Red"]'[/COLOR]SQL_HOST[COLOR="Red"]'[/COLOR],'localahost'); however, in same define function i see double quotation in another source define([COLOR="Red"][COLOR="Red"]"[/COLOR][/COLOR]CONSTANT[COLOR="Red"]"[/COLOR], "Hello world."); Thanks.[/QUOTE] Most of the time it does not …

Member Avatar for fatcat2010
0
125

The End.