Jump to content

anupamsaha

Members
  • Posts

    251
  • Joined

  • Last visited

    Never

Everything posted by anupamsaha

  1. Yes, I know that I didn't take the reverse order into account as that can be checked by swapping the two strings from the combination.
  2. That's correct. Text file will have lines with strings in it and not array. Actually, the text file will have the strings those MUST be in the array. But, the array might have some words those are not part of the actual string. Make sense?
  3. 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!
  4. 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!
  5. Read the eval() in PHP http://php.net/manual/en/function.eval.php. But, be very careful because anybody can input any PHP command to blow your server. Sanitize users' input before you use them.
  6. 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>
  7. 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>
  8. 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?
  9. 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.
  10. 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!
  11. 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
  12. 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'])
  13. Yes. You can. I have done this and sure about it. What's the issue that you are facing?
  14. 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.
  15. 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 ---- // ?>
  16. <?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 ?>
  17. Great. Let me know how it goes and if you need any further help on this.
  18. 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!
  19. In your view of this topic, you should see a button called "resolve". Please check.
  20. 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.
  21. 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
  22. 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());
×
×
  • Create New...

Important Information

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.