
phdphd
Members-
Posts
248 -
Joined
-
Last visited
Everything posted by phdphd
-
Thank you, Jacques! Very much appreciated (as usual ).
-
Thanks Jacques. What would be the right password_verify() syntax ? I applied your function to "hello" as password, and obtained string(60) "$2y$12$4HJ4ttxHjrmhnNamYZPftehUIlZ.IkQndxDca50kid.lmSXLjhTqy". Then I ran : $hash = '$2y$12$4HJ4ttxHjrmhnNamYZPftehUIlZ.IkQndxDca50kid.lmSXLjhTqy'; if (password_verify('hello', $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } And got "Invalid password."
-
Not so much related with the above subject/comments, but might be interesting to know; I have been playing with an online php editor (http://sandbox.onlinephpfunctions.com/). $string='hel$lo'; echo 'string is '.$string."\n";//displays "string is hel$lo" echo password_hash($string, PASSWORD_DEFAULT)."\n"; is ok, while $string="hel$lo"; echo 'string is '.$string."\n";//displays "string is hel" echo password_hash($string, PASSWORD_DEFAULT)."\n"; would still generate a hash, but also an "Undefined variable: lo" warning, apparently due to double quotes. Actually only "hel" is taken into account.
-
Thanks, Muddy_Funster.
-
Hi All, I guess that people who developed password_hash did it with salt uniqueness in mind. However is it possible that two users defining the same password get the same "hash-salted" version of it ? If so, how to prevent this situation? Thanks.
-
Thanks, Jacques1.
-
Hi All, I am very new to Opcache. Suppose I have a form in File_A.php with an input field where users enter their name. When they validate the form, their name is saved in a variable, and File_B.php is called and displays "Your name is [variable_value]". Let's say Peter fills the form, then Mary does. To which extend does Opcache come into play in this scenario ? Is there a risk that Mary gets "Your name is Peter"? Thanks.
-
Thanks to all!
-
Thanks.
-
Hi All, Among other data, my database stores passwords. In the case of individuals, the "forgotten password"/"secret question" approach is OK to recover the password. However, I am not sure for companies, where staff changes from day to day and not everyone would give the same answer to "what is the maiden name of your mother?". So suppose that for whatever reason a company loses the password - what is the best approach to recover it? Thanks for your opinion.
-
I guess this is because the JS is not dependent on an event being trigged.
-
Hi all, I managed to display multiple Google maps on same page. Here is my sample code (mix of html/js): <body> <script src="https://maps.googleapis.com/maps/api/js"></script> <script> function initialize(param1,param2,param3) { var mapCanvas = document.getElementById(param1); var mapOptions = { center: new google.maps.LatLng(param2, param3), zoom: 17, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(mapCanvas, mapOptions) }; </script> <div id="map_canvas"><script>initialize('map_canvas',51.5403,-2.5463);</script></div> <div id="map_canvas2"><script>initialize('map_canvas2',41.5403,-2.5463);</script></div> </body> This works. However it does not if I follow the best pratice of putting the js code at the end, right before the closing body tag. (On the actual page, the number of maps is not fixed, and varies upon user's choices.) Thanks for your help!
-
The use of possessive quantifiers is indeed very efficient! Thanks for this great tip.
-
Hi All, I have a preg_match that checks if a string is made up of a number, or of a comma-separated list of numbers. The regex is : ^[0-9]+(,[0-9]+)*$ When the form is processed, the browser crashes if the string is very long. (It does not if I just do not run the preg_match). I guess the solution might be adjusting the pcre.backtrack_limit setting. However I would like to know if there is a better solution than the above preg_match to check the string. Thanks.
-
thanks!
-
Hi all. I have some jquery that adds a class to siblings on hover and removes it when hovering ends. So this works [selector_syntax].hover( function(){$(this).parent().parent().siblings().addClass('fade');}, function(){$(this).parent().parent().siblings().removeClass('fade');} ) But this does not. [selector_syntax].hover( function(){$(this).parent().parent().siblings().addClass('fade');}, setTimeout(function(){$(this).parent().parent().siblings().removeClass('fade');}, 3000); ) Thanks for you help!
-
Mysqli : "There is no next result set" error message
phdphd replied to phdphd's topic in PHP Coding Help
Prepending mysqli_next_result with an @ would offer a visual solution, but would it be a good technical one ? -
Hi All, I get the following message when running a multiline query through mysqli. Here is my simplified code : $sql='SELECT CURRENT_USER();'; $sql.='SELECT CURRENT_time();'; $rs = @mysqli_multi_query($link,$sql); if (!$rs) { } else { do { if ($rs = mysqli_store_result($link)) { while ($row = mysqli_fetch_row($rs)) { echo "<br/> ". $row[0]; } mysqli_free_result($rs); } if (mysqli_more_results($link)) { echo "<br/>-----------------<br/>"; } } while (mysqli_next_result($link)); } If I use "while (mysqli_next_result($link) && mysqli_more_results($link));" instead of "while (mysqli_next_result($link))", I get no error message, but the current time (returned by the second query) won't display. Thanks for your help!
-
Selecting All Rows With Multiple Conditions In 2 Other Tables
phdphd replied to phdphd's topic in MySQL Help
Thank you! -
Selecting All Rows With Multiple Conditions In 2 Other Tables
phdphd replied to phdphd's topic in MySQL Help
Based on the fiddle provided, let's say the tables have following structure and contents: -- ----------------------------------------------------- -- Table `products` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `products` ( `id` INT NULL AUTO_INCREMENT, `name` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `properties` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `properties` ( `id` INT NOT NULL AUTO_INCREMENT, `product_id` INT NULL, `key` VARCHAR(45) NULL, `value` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `properties2` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `properties2` ( `id` INT NOT NULL AUTO_INCREMENT, `product_id` INT NULL, `continent` VARCHAR(45) NULL, `country` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Data for table `products` -- ----------------------------------------------------- INSERT INTO `products` (`id`, `name`) VALUES (1, 'English Book with AudioCD'); INSERT INTO `products` (`id`, `name`) VALUES (2, 'Polish Book'); -- ----------------------------------------------------- -- Data for table `properties` -- ----------------------------------------------------- INSERT INTO `properties` (`id`, `product_id`, `key`, `value`) VALUES (1, 1, 'Format', 'Book'); INSERT INTO `properties` (`id`, `product_id`, `key`, `value`) VALUES (2, 1, 'Format', 'Audio'); INSERT INTO `properties` (`id`, `product_id`, `key`, `value`) VALUES (3, 2, 'Format', 'Book'); INSERT INTO `properties` (`id`, `product_id`, `key`, `value`) VALUES (4, 1, 'Language', 'English'); INSERT INTO `properties` (`id`, `product_id`, `key`, `value`) VALUES (5, 2, 'Language', 'Polish'); -- ----------------------------------------------------- -- Data for table `properties2` -- ----------------------------------------------------- INSERT INTO `properties2` (`id`, `product_id`, `continent`, `country`) VALUES (1, 1, 'Asia', 'China'); INSERT INTO `properties2` (`id`, `product_id`, `continent`, `country`) VALUES (2, 1, 'Asia', 'India'); INSERT INTO `properties2` (`id`, `product_id`, `continent`, `country`) VALUES (3, 2, 'Asia', 'China'); INSERT INTO `properties2` (`id`, `product_id`, `continent`, `country`) VALUES (4, 1, 'Europe', 'France'); INSERT INTO `properties2` (`id`, `product_id`, `continent`, `country`) VALUES (5, 2, 'Europe', 'UK'); Let's say I want to find products in table "products" that have Format/Book and Format/Audio as key/value (table "properties"), and Asia/China and Asia/India as continent/country (table "properties2"). The following does not work : select p.id, p.name from products p inner join properties t on p.id = t.product_id inner join properties2 t2 on p.id = t2.product_id where t.value in ('Book', 'Audio') group by p.id, p.name having count(distinct t.value) = 2 and t2.country in ('China', 'India') group by p.id, p.name having count(distinct t2.country) = 2 I get the message 'check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by p.id, p.name having count(distinct t2.country) = 2" Thanks. -
Hi All, I am trying to find a way to select all rows in one table that meet multiple conditions in 2 other tables, using a combination of inner join, group by, having count syntax. I know how to do it with just one other table, but not with 2. There is a good fiddle example with one table here : http://sqlfiddle.com/#!2/58b4b1/8 I tried to create and fill another table, then edit the existing query accordingly, but I always get a syntax error message. I do not even know if it is technically feasible. Thanks for your help !
-
Me again. I reopen the topic despite the main point was solved. Is it possible to prepend the div with a string? I tried to add the following at the beginning of the JS function, but it does not fire. var printElement = 'text to add before the div to print<br>'; printElement+=document.getElementById(el); Thanks.
-
Hi All, My page contains a JS function that enables to print the content of a DIV, and contains also a jQuery Autocomplete textbox that does not belong to that DIV. Here is the JS for printing the div function printContent(el){ var restorepage = document.body.innerHTML; var printcontent=document.getElementById(el).innerHTML; document.body.innerHTML = printcontent; window.print(); document.body.innerHTML = restorepage; } The HTML attached to it is <div id="div1">DIV 1 content... </div> <button onclick="printContent('div1')">Print Content</button> If the user clicks the button to print the content of the DIV, they cannot afterwards make use of the Autocomplete textbox. It seems the issue occurs with any kind of jQuery UI, not just autocomplete. In this case, the HTML of the Autocomplete is <div class="ui-widget"> <label for="tags">Tags: </label> <input id="tags" /> </div> and the script $(function () { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl" ]; $("#tags").autocomplete({ source: availableTags, minLength: 0, delay: 0 }); }); jquery-ui-1.10.3.custom.css, jquery-1.9.1.js and jquery-ui-1.10.3.custom.js are used. Any idea of how to keep the jQuery UI functional after the div-printing JS function has been used ? Thanks for your help.