
anupamsaha
Members-
Posts
251 -
Joined
-
Last visited
Never
Everything posted by anupamsaha
-
Thanks @xyph for your note. Let me elaborate my problem here. I have a text file where the actual strings are stored. By "actual", I mean the strings to be searched. These strings are combination of two strings. Now, I have another array where all thestrings are scrambled. Text file (wordlists.txt) milliontrillion unitdecimal crossstraight sumdivide ... The scrambled array: array('divide', 'trillion', 'decimal', 'million', 'straight', 'sum', 'unit',....); I want to traverse through the array and concatenate two strings and mark which are the strings are found from the text file. Any idea about such traversing algorithm which is fast? Thanks!
-
Hello, I have an array as follows: $a = array('a1', 'b1', 'c1'); // this can grow to 1000+ strings as array elements My objective is to traverse through the array quickly and create combination of strings taking two at a time. This means, the following will be the output: array(array('a1','b1'), array('a1','c1'), array('b1','c1')); // no need to create the reverse combinations I wrote the following code to achieve the same, but it's really really slow for a long array (for say, number of elements 1000+) <?php $words = array('a1', 'b1', 'c1'); $result = array(); do { $word1 = array_shift($words); foreach($words as $word2) { $result[] = array($word1, $word2); } } while(count($words)>0); print_r($result); ?> Can anybody help me to implement a faster solution for this? Thanks!
-
Here you go <table> <tr> <td>Enter function y prime:</td> <td><input type="text" size="50" maxlength="" name="yprime" value="<?php echo (isset($_POST['yprime']) ? $_POST['yprime'] : '')?>" /></td> </tr> <tr> <td>Enter number of partitions:</td> <td><input type="text" size="7" maxlength="7" name="partitions" value="<?php echo (isset($_POST['partitions']) ? $_POST['partitions'] : '')?>" /></td> </tr> <tr> <td>Enter initial x value, x(0):</td> <td><input type="text" size="3" maxlength="3" name="initialx" value="<?php echo (isset($_POST['initialx']) ? $_POST['initialx'] : '')?>" /></td> </tr> <tr> <td>Enter the ending x value:</td> <td><input type="text" size="3" maxlength="3" name="endingx" value="<?php echo (isset($_POST['endingx']) ? $_POST['endingx'] : '')?>" /></td> </tr> <tr> <td>Enter initial y value, y(0):</td> <td><input type="text" size="3" maxlength="3" name="initialy" value="<?php echo (isset($_POST['initialy']) ? $_POST['initialy'] : '')?>" /></td> </tr> </table>
-
Seems you have missed to check whether the form is posted or not. Here is the code that I edited. Let us know if it works or not. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><?php function dydx($x,$y){ $equation = 3 * pow($x, 2); return $equation; } ?> <table> <tr> <td>Enter number of partitions:</td> <td><input type="text" size="7" maxlength="7" name="partitions" value="" /></td> </tr> <tr> <td>Enter initial x value, x(0):</td> <td><input type="text" size="3" maxlength="3" name="initialx" value="" /></td> </tr> <tr> <td>Enter the ending x value:</td> <td><input type="text" size="3" maxlength="3" name="endingx" value="" /></td> </tr> <tr> <td>Enter initial y value, y(0):</td> <td><input type="text" size="3" maxlength="3" name="initialy" value="" /></td> </tr> </table> </br> <input type="submit" name="runge kutta name" value="Run Program" /> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' ) { // make sure that the form is posted $partitions = $_POST['partitions']; $initialx = $_POST['initialx']; $endingx = $_POST['endingx']; $initialy = $_POST['initialy']; if ($_POST['partitions'] != 0) { $h = ($endingx - $initialx)/$partitions; } $a[1] = $initialx; $b[1] = $initialy; for ($i = 1; $i <= $partitions; $i++) { $k1 = dydx($a[$i], $b[$i]); $k2 = dydx($a[$i] + (1/2)*$h, $b[$i] + (1/2)*$h*$k1); $k3 = dydx($a[$i] + (1/2)*$h, $b[$i] + (1/2)*$h*$k2); $k4 = dydx($a[$i] + $h, $b[$i] + $h*$k3); $a[$i + 1] = $a[$i] + $h; $b[$i + 1] = $b[$i] + (1/6)*$h*($k1 + 2*$k2 + 2*$k3 + $k4); } for ($i = 1; $i <= $partitions + 1; $i++) { $xyarray["$a[$i]"] = $b[$i]; } $_SESSION['graph'] = $xyarray; ?> </br> </br> Choose a partition of X: <select name="output"> <?php for ($i = 1; $i <= $partitions + 1; $i++) { echo "<option value=\"$a[$i]\">$a[$i]</option>\n"; } } // if ($_SERVER['REQUEST_METHOD'] == 'POST' ) ends ?> </form>
-
do we need to install mysql & apache server b4 easyphp
anupamsaha replied to sonalee's topic in Third Party Scripts
Moderator has indicated to write full English instead of the shorter version like 'd' for 'the' etc. Each forum has a decorum of communicating with others. Please follow the same as the moderator suggested. What error do you see at the end? -
do we need to install mysql & apache server b4 easyphp
anupamsaha replied to sonalee's topic in Third Party Scripts
Seems a big mess is there already. I would suggest to take backup of your scripts and uninstall MySQL, PHP, Apache, EasyPHP and then install EasyPHP again. -
do we need to install mysql & apache server b4 easyphp
anupamsaha replied to sonalee's topic in Third Party Scripts
Yes. Only install EasyPHP. -
do we need to install mysql & apache server b4 easyphp
anupamsaha replied to sonalee's topic in Third Party Scripts
EasyPHP is a WAMP package including the scripting language PHP, the web server Apache, the SQL server MySQL, as well as easy development tools such as the database manager PhpMyAdmin and the debugger Xdebug. Nothing to configure. It's already done! -
Please provide the code here.
-
Replace Each Instance of a substring with values from an array.
anupamsaha replied to proggR's topic in PHP Coding Help
Did you close the single quote correctly? $db->query = 'SELECT * FROM users WHERE user_name = :name AND user_role = :role'; // I have closed the single quote -
Help with inserting math captcha in registration form
anupamsaha replied to sofia403's topic in PHP Coding Help
The issue that you are facing due to duplicate form element name "Submit" for both the submit button and captcha input text. The submit button overrides the value of captcha field. Change <td><input type="text" name="Submit" value="what's the result?" onclick="this.value=''" /></td> To <td><input type="text" name="security" value="what's the result?" onclick="this.value=''" /></td> Also, change if($_POST['Submit'] != $_SESSION['security_number']) To if($_POST['security'] != $_SESSION['security_number']) -
Yes. You can. I have done this and sure about it. What's the issue that you are facing?
-
You need not to use mysql_real_escape_string() while you extract variable value from the SESSION. Try $userId = $_SESSION['MM_Username']; Also, please echo the SQL query that is creating the error and post it here.
-
Try the following: <?php if(isset($_GET['id'])) { $conn = mysql_connect("database", "username", "password"); mysql_select_db("data"); $game_id = (int) $_GET['id']; // typecast to integer type to have a safe input from the URL querystring $sql = "UPDATE `dbname` SET `fldPlays` = `fldPlays` + 1 WHERE `fldID`='$game_id' LIMIT 1"; mysql_query($sql) or die(mysql_error()); //---- your rest of the code goes here ---- // ?>
-
<?php $a = 350000; $b = 360000000; $hmm = $a / $b; echo sprintf("%.10f", $hmm); // change 10 to any number that you want to display in the result after the decimal ?>
-
Great. Let me know how it goes and if you need any further help on this.
-
There is no way to decrypt a hashed password, if you encrypted it using MD5() command or so. The best way to do it to generate a random password again and send it to the user requesting the forgot password form. But, this form might be accessed by an anonymous user and the password can be changed for the concerned user. So, the ideal way that I can suggest is the following: 1. Creates a column called "temp_pw" (temporary password) in your database table. 2. User requests a forgot password form and enters username and email. 3. Upon successful verification, a random password is generated and store into the "temp_pw" field. 4. System sends an email to the actual user's email address with a link. 5. Actual user clicks on the link and go the page. When user clicks on the link, system will now update the "pw" (actual password) column with the value of "temp_pw" to make sure that the user receives the email and clicked on it. This way a old password of the actual user will be saved in case he/she did not opted for the forgot password form. Hope it helps!
-
In your view of this topic, you should see a button called "resolve". Please check.
-
Verification of Email thru email confirmation link-I'm stuck
anupamsaha replied to bmconnect's topic in PHP Coding Help
Please add the following at the top of the PHP script which creates a blank output. error_reporting(E_ALL); ini_set("display_errors", 1); This will enable you to see what the error is. -
Please mark it "resolved".
-
You should research and code by yourself. If you have any issues, post it here. See these links: http://php.net/manual/en/ref.curl.php http://php.net/manual/en/curl.examples.php
-
Do you have an email address column in the database table? If yes, please change the SQL query as follows. I am assuming that the email address column name is "email" (please change it to actual): $query="SELECT `pw` FROM `user` WHERE `uname`='$name' AND `email` = '$em'" or die(mysql_error());