$myResult = mysqli_query($con, "SELECT * FROM users WHERE Password=$_POST=['password']");   It won't let me put my $_POST. I need to have it adaptable so it won't be set to just one password.   Here's the rest of my code, this is a localhost learning thing, so I'm not giving anything away  &lt;?php $con=mysqli_connect('localhost','root','Llamabash','whales'); if (mysqli_connect_errno()) {     echo'Database connection error: ' . mysqli_connect_error();     echo'&lt;br&gt;'; } else {     echo'Connected to database';     echo'&lt;br&gt;'; } //works fine up till here $myResult = mysqli_query($con, "SELECT * FROM users WHERE Password"); $checkUsername = $_POST['username']; $checkPassword = $_POST['password']; while($check = mysqli_fetch_array($myResult,MYSQLI_ASSOC)) {     //echo $check;     //echo '&lt;br&gt;';     if($checkUsername == $check['Username'] &amp;&amp; $checkPassword == $check['Password']) {         echo'&lt;h1&gt;Logged in.&lt;/h1&gt;';         echo'&lt;h1&gt;Hello ' . $check['Username'] . '!&lt;/h1&gt;';     } elseif ($checkUsername == NULL) {         echo'&lt;p&gt;Please Enter Username.&lt;/p&gt;';     } elseif ($checkPassword == NULL) {         echo'&lt;p&gt;Please Enter Password.&lt;/p&gt;';     } elseif ($checkPassword != $check['Password'] or $checkUsername != $check['Username']) {         echo'&lt;p&gt;The Username or Password is incorrect.&lt;/p&gt;';     } else {         echo 'something weird is happening';           echo '&lt;br&gt;';     } }  mysqli_close($con); echo'Exited database.'; ?&gt;
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to , like in the following example:  $unsafe_variable = $_POST['user_input'];   mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");   That's because the user can input something like value'); DROP TABLE table;--, and the query becomes:  INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')   What can be done to prevent this from happening?
How to format table with long column head entries? How to prove $( A \times B ) \cap ( C \times D ) = ( A \cap C ) \times ( B \cap D )$ ? Replacements for switch statement in Python? I want to write a function in Python that returns different fixed values based on the value of an input index.    In other languages I would use a switch or case statement, but Python does not appear to have a switch statement.  What are the recommended Python solutions in this scenario? How to create my own math operator with limits? How can i write my own math operator with limits? I want it to look like:  \sum\limits_{e=1}^{m} but with a capital A (if possible bigger than the normal text) instead of the sum.  Thanks for the help! How to determine the point of intersection of two lines? I have two lines say P1( 0, -1, 0, -1 ) and P2( -1, 0, 0, -1 ). Since I'm working in 2D, there is no Z component. The x,y,z components are normals and the w component is the distance from origin. I am not given the origin or any points on the line.  What method should I use to programmatically determine the point of intersection for these two lines? Kali Linux: apt update returns "Hash Sum mismatch" error I'm experiencing exactly the same issue as described in this question: . Before you mark this as a duplicate however, I have tried the solutions posted there, as well as on numerous other sites, including:  sudo apt-get clean sudo rm -rf /var/lib/apt/lists/* sudo apt-get update   Editing /etc/apt/sources.list with alternate official mirrors, such as  deb http://mirrors.ocf.berkeley.edu/kali kali-rolling main non-free contrib or deb https://http.kali.org/kali kali-rolling main non-free contrib  Everything worked after I first imported the VM. I ran sudo apt update and it found some ~650 packages to upgrade. I ran sudo apt upgrade and it encountered an error partway through. That error was solved using sudo apt --fix-broken install, but that is when this hash sum error began. Unfortunately due to hours of troubleshooting I no longer have the details of the earlier error, but I believe it was an error extracting a package due to corrupt data.  I've tried multiple official mirrors, but I get the same error. Additionally, when I downloaded the Packages.gz file  on my Windows machine (VM host) and computed the SHA256 hash, I got the exact hash that apt printed as the expected value. This led me to believe that the error was not with the mirror but with my VM.  The next thing I tried was wget https://mirrors.ocf.berkeley.edu/kali/dists/kali-rolling/main/binary-amd64/Packages.gz followed by sha256sum Packages.gz, which provided yet another different hash output.  To be clear, I have seen 3 different hashes for the same file:   The "correct" hash shown by apt as expected, which is the one that windows also produced after downloading the file using a browser The incorrect hash calculated by apt, which led to the error A different hash calculated by sha256sum after downloading the file using wget using the same URL as for the browser download   I should also note that I have only been referencing the SHA256 hash in each step. The other hash functions are also mismatched when I run sudo apt update, but the file size is the same. I had considered that downloads might be failing due to limited disk space (it is a VM after all) but I don't think that's the case.  What am I missing? This is a summary of the excerpt:  Given that we have:  *$10^9$ people  *each person has a chance of 0.01 of going to a hotel  *we have $10^5$ hotels, each hotel holds 100 people  *Thus, $P(2 \text{ persons meet on the same hotel in any given day}) = 0.01 \cdot 0.01 \cdot 10^{-5}$  *and $P(2\text{ persons on the same hotel in $2$ day}) = P(2 \text{ persons on the same hotel in any given days})^2 = 10^{-18}$  the book "Mining of Massive Dataset" said that the expected number of pairs who stay in the same hotel for 2 days is:  $P(2 \text{ persons on the same hotel in $2$ days}) \cdot ( \text{number of pairs of people} ) \cdot (\text{number of pairs of days})$  this is the part where I got stuck. Can't understand how it come to this derivation. Can anybody explain it in more elaborate detail.  You can find the content on page 6 of this link:  (it is freely available) The most efficient way to implement an integer based power function pow(int, int) What is the most efficient way given to raise an integer to the power of another integer in C?  // 2^3 pow(2,3) == 8  // 5^5 pow(5,5) == 3125 Binary search (bisection) in Python Is there a library function that performs binary search on a list/tuple and return the position of the item if found and 'False' (-1, None, etc.) if not?  I found the functions bisect_left/right in the , but they still return a position even if the item is not in the list. That's perfectly fine for their intended usage, but I just want to know if an item is in the list or not (don't want to insert anything).  I thought of using bisect_left and then checking if the item at that position is equal to what I'm searching, but that seems cumbersome (and I also need to do bounds checking if the number can be larger than the largest number in my list). If there is a nicer method I'd like to know about it.  Edit To clarify what I need this for: I'm aware that a dictionary would be very well suited for this, but I'm trying to keep the memory consumption as low as possible. My intended usage would be a sort of double-way look-up table. I have in the table a list of values and I need to be able to access the values based on their index. And also I want to be able to find the index of a particular value or None if the value is not in the list.  Using a dictionary for this would be the fastest way, but would (approximately) double the memory requirements.  I was asking this question thinking that I may have overlooked something in the Python libraries. It seems I'll have to write my own code, as Moe suggested. Can I launch a graphical program on another user's desktop as root? Following are other questions which I think I need to know:   From a non X Session? (meaning root isn't logged into X) If multiple people were logged in on X, could I auto-detect who was on which screen, and thus programmatically detect which screen I need to launch the app on? Can I launch the app as the user? ( ok I'm 99.999% sure this is a yes ) Can I detect if users of group X are logged in to X? Where will changes and fixes to guides and manuals for 5e be found? I'm interested in a grappler build, among others, and don't know where to look to see if the last bullet for the grappler feat has been changed. The grappler example aside, it should be useful to know for future fixes. I have 16GB RAM. Do I need 32GB swap? I read many places that the rule of thumb for swap space is to double the amount of physical RAM. However, 32 GB does seem a LOT. Do I need that much? Do I need it at all with this high amount of physical RAM? Why do statisticians say a non-significant result means "you can't reject the null" as opposed to accepting the null hypothesis? Traditional statistical tests, like the two sample t-test, focus on trying to eliminate the hypothesis that there is no difference between a function of two independent samples. Then, we choose a confidence level and say that if the difference of means is beyond the 95% level, we can reject the null hypothesis. If not, we "can't reject the null hypothesis". This seems to imply that we can't accept it either. Does it mean we're not sure if the null hypothesis is true?   Now, I want to design a test where my hypothesis is that a function of two samples is the same (which is the opposite of traditional statistics tests where the hypothesis is that the two samples are different). So, my null hypothesis becomes that the two samples are different. How should I design such a test? Will it be as simple as saying that if the p-value is lesser than 5% we can accept the hypothesis that there is no significant difference? How does 3-wire RTD or resistance measurement works in bridge of wheatstone? I cannot understand how 3-wire measurement will improve the resistance measurement.    They say that IF lead resistance \$ R_L \$ is the same, it will compensate. How can this happen?  If bridge is balanced (without \$ R_L \$):  \$ \frac {R_1}{R_2} = \frac {R_g}{R_3} \$  If \$ R_L \$ is added: \$ \frac {R1}{R2}= \frac {R_g+R_L}{R_3+R_L} \$  \$ \frac {R_g}{R_3} \$ is not same as \$ \frac {R_g+R_L}{R_3+R_L}\$; is this true only if \$ R_G=R_3 \$ in the beginning? So this means that \$R_L\$ does not get compensated? How do you clear a stringstream variable? I remember (vaguely) reading somewhere that it is wrong to use the present perfect when the subject of a sentence is someone who is long dead:     *Einstein has visited the Philippines.   My question is, What if the dead person is not the subject but an object:     Leo is the best president our country has/had ever had. (The ones who   succeeded him were inferior, even our current president.)   Which tense is proper here How to interleave the lines of two or more files? I have tried to get the 2 files output in a single file.  I have tried below command:  cat file1 file2   but here file2 data is appending to file1.  What I need is file1 1st line followed by file2 first line, and file1 second line followed by file2 second line etc.  Can anybody tell me how to do this in a simple way? "happen to be" and "happen to have" - expressions of probability? Based on Logman dictionary:       happen to do something: if you happen to do something, you do it by chance.   for example take a look at these examples:     They happen to be unemployed at the time. I happen to have a degree in computer science.    So based on the definition of the happen to do something, first one means they are probably unemployed at the time. and the second one means I probably have a degree in computer science.     Am I right? My wireless/WiFi connection does not work. What information is needed to diagnose the issue? Your situation   You have successfully installed Ubuntu.  You have just downloaded and booted Ubuntu live media.  The latest LTS (see also ) or latest non-LTS release are preferred. See the list of  that are currently supported.) You upgraded your Ubuntu installation to the latest release that the software updater offered you. WiFi worked before, but not now on the new release. You  to new hardware.   Your problem   The wireless of your laptop or desktop is not working. You tried switching the wireless switch off and on and you tried rebooting several times, but you don't see any WiFi access points. You can see your wireless access point, but you cannot establish a connection. You want to analyze the problem, but you don't know where to start or what information you can provide.   This question and answer was written to give people the wireless script that will provide the information needed in most cases to diagnose their wireless issue's.   Related questions Help with proving that $\pi$ is irrational