SQL Injection Protection - Where and When I'm building a website which uses information passed through a URL to pick out information from a database table, but it was brought to my attention that doing this may cause a SQL Injection. As I thought this was only an issue where you were inserting information into a database, I'm a bit confused as to when, how and where you should protect your code.  Currently I have a url which looks like:  www.website.com/article.php?title=title&amp;id=1   Which is shortened in htaccess to www.website.com/article/title/1  In my article.php page I then have:  &lt;?php if(isset($_GET["id"])){$url_id = $_GET["id"];}else{ header("Location: $site_url"); exit(); }; ?&gt; &lt;?php if(isset($_GET["title"])){$url_title = $_GET["title"];}else{ header("Location: $site_url"); exit(); }; ?&gt; &lt;?php $article_sql = "SELECT ...   I currently use mysqli_real_escape_string to prevent SQL Injection threats, but I'm unsure where to use it here. I'm guessing that adding...  ... &lt;?php if(isset($_GET["title"])){$url_title = $_GET["title"];}else{ header("Location: $site_url"); exit(); }; ?&gt; &lt;?php $url_id = mysqli_real_escape_string($url_id); // ADDED $url_title = mysqli_real_escape_string($url_title); // ADDED ?&gt; &lt;?php $article_sql = "SELECT  ...   Should do the trick, but is this correct?
How can I prevent SQL injection in PHP? 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?
Comment submission broken for comments that end with @username Saudi Arabia Transit Visa I am travelling to Rome along with five other members (all in a family) from Bengaluru via Jeddah. My layover in Jeddah is 13.5 hours before i catch a connecting Flight to Rome. I won't be moving out of airport in Jeddah. Do I still need a Transit visa in Saudi Arabia. Was V'ger responsible for the creation of the Borg? I remember reading somewhere a theory that  (the being that the Voyager probe had become in Star Trek: The Motion Picture) was somehow responsible for the creation of the Borg.  Is this canonical?  Where does the theory come from?  And how exactly did it go down? Compare two dates with JavaScript What would have happened if Voldemort had won Priori Incantatem before Nagini had been decapitated? As wielder of an elder wand that belonged to Harry, during Voldemort’s Last Stand, there are two instances of Priori Incantatem occurring, back to back.  Basically, the current order of events makes total sense. Since Nagini was the last horcrux, when the body died, the fragment of Voldemort’s soul locked in it was released. This disrupted the first instance of Priori Incantatem, and Voldemort was now significantly weaker than Harry – so Harry won. Naturally, the Elder Wand’s killing spell was reflected back on Voldemort because of Priori Incantatem outcome.   But, if Voldemort was just told by Harry that the Elder Wand wouldn’t work against Harry because it belonged to Harry, and was a wand that would win any duel for its master, why would Voldemort willingly try and continue to use it? This is doubly so, since after he had cast the killing spell on Harry once it had only torn Voldemort’s soul from Harry’s body – wouldn’t that even imply that the Elder Wand would realistically refuse almost any attempted direct harm against its owner?  Also, wouldn’t a first refusal of the Elder Wand to kill it’s own master also imply an additional refusal even if Voldemort had won either of the Priori Incantatem matches (in which case, the worst that could happen in this line of thinking is, Voldemort has Harry’s wand since Harry’s spell is Expelliarmus)? Fonts larger than \Huge? How can I make text that is larger than the size of the output of {\Huge ...}?   I would like to be able to make text arbitrarily large (even if that is done by some suboptimal scaling routine). How to change the size of desktop icons? I tried gconf-editor as given at  .  I am not getting the option for changing size at app &gt; nautilus &gt; icon_view.  I am using Ubuntu 11.10. Kindly help me in changing default icon size.   I want to make them small. Setting knots in natural cubic splines in R I have data with many correlated features, and I want to start by reducing the features with a smooth basis function, before running an LDA. I'm trying to use natural cubic splines in the splines package with the ns function.  How do I go about assigning the knots?  Here's the basic R code:  library(splines) lda.pred &lt;- lda(y ~ ns(x, knots=5))   But I have no idea about how to chose the knots in ns. Draw Lewis structures like a book I want to draw a Lewis structure as in the picture. I tried to do with chemfig but does not perform the separation of the points and a minus in the superscript. I have the following reference:  @MISC{EX2012,   author = {{S}ingle {A}uthor {O}rganization},   year = {2012},   title = {Example} }   A citation for this is breaking after "Author", but extending beyond the margin, as shown in the following example layout in the PDF:  Demo text demo text demo to margin Demo text which cites it (Single Author Organization, 2012) and flows over the margin.   How can I solve this? I am using natbib and citing with \citep{EX2012}. Enumerate after \label I have the following code:  \usepackage{hyperref} \newtheorem{thm}{Theorem}  \begin{thm} \label{mythm}    \begin{enumerate}       \item     \end{enumerate} \end{thm}  \ref{mythm}   The ref prints the right number. However, when I click on it, it will lead me to a wrong page (basically, to the beginning of the document).  pdflatex also has some warning.  If I add $ $ between \begin{thm} and \begin{enumerate}, the problem disappears, but now, the enumeration starts a new line.  Is there any way to fix this? What is the best way to iterate over a dictionary? I've seen a few different ways to iterate over a dictionary in C#.  Is there a standard way? I want to know if there is another way to solve the equation:  $$(x+1)^y-x^z=1$$  for positive integers $x,y,z$ greater than $1$ without using the Catalan identity. Does exist? By now I only know that $x\mid y$. If $\int_0^1 f(x)x^n \ dx=0$ for every $n$, then $f=0$. Origin —  Elementary Number Theory — Jones — p35 — Exercise 2.17 — For which primes $p$ is $p^2 + 2$ also prime? Only for $p = 3$. If $p \neq 3$ then $p = 3q ± 1$ for some integer $q$, so $p^2 + 2 = 9q^2 ± 6q + 3$ is divisible by $3$, and is therefore composite. (1) The key here looks like writing $p = 3q ± 1$. Where does this hail from? I know $3q - 1, 3q, 3q + 1$ are consecutive. $p$ is prime therefore $p \neq 3q$? (2) How can you prefigure $p = 3$ is the only solution? Does $p^2 + 2$ expose this? On an exam, I can't calculate $p^2 + 2$ for many primes $p$ with a computer — or make random conjectures. I am writing a script, which I would like to spice up a bit.  What I need, is a loop, which takes one letter at a time, including space, and then write it on the screen, like an old typewriter would do.  I would write some kind of pause/sleep between the typing, so it would look retro like. Better extensible arrows Split Line at Points not splitting at every point in ArcGIS for Desktop? Why does  not split at every point encountered, even if run in an iterative fashion?  Following the suggestions of a thread here and several others, I made a set of points in order to split polylines at specified intervals. In order to do this, I used linear referencing to turn my lines into routes. Then, I exported the attribute table, divided each length by 5, and set points at multiples of 1/5 the length of the line. I used this as the event table to create a layer of events. So, each line has 4 equally spaced points along it, and I thus ultimately need the 5 segments separated by those points.  Curiously, though, when I try to do the second part "Split Line at Point," it seems that only one point is used on a given line at a time, and I'm not sure how it chooses the point (maybe order in its attribute table?) I could run the tool multiple times, but this doesn't seem to solve the problem either. For example, I could see how it would continue splitting segments as more segments are generated, but on e.g. the 4th run I see that some lines are still only split 3 times, even though there is a point within a line segment that was never split and existed before I ran the tool. I'm not sure how the splits are generated, but in any case, it doesn't seem to do what I want it to do, which is produce a split at "each" point.  What should I do to split lines at ALL points along the line? A priori power analysis for generalized linear mixed-effects model Let's say I have a data set (with a binary DV) which I used a generalized linear mixed-effects model on. I am currently trying to run a simulation-based power analysis to determine the sample size I should try to collect for a replication attempt.   I know about the  function for fitted lme4 model objects, which will create simulated responses that follow the size and structure of the actual dataset.  My question is, how can I use this fitted model object to run an a-priori power analysis for my replication?. In other words, is there an easy way to extract the necessary information from the simulate function, vary the sample size, then to simulate responses?  EDIT:  Here is a simple example with ten subjects that should give me a good starting place. The data here are totally fake so the effects are not close to what I have in the pilot data.  The two variables of interest are age in months (between subjects) and whether the stimulus is "similar" or "dissimilar" (within subjects). Each individual is exposed to three items within each similarity group, for a total of six binary responses for each subject. As seen in the model, I am interested in a possible interaction between age and similarity and include a random slope of similarity to do this.   Let me know if I need to modify anything/provide more information to make things easier.   set.seed(28)  fakeData &lt;- data.frame(ID = rep(1:10, each = 6),                        months = rep(round(runif(10, min = 60, max = 80)), each = 18),                        similarity = rep(c("Sim", "Dissim"), each = 3),                        response = sample(c(0, 1), 60, replace = TRUE))  fakeModel &lt;- glmer(response ~ months * similarity + (similarity | ID), family = binomial, data = fakeData) summary(fakeModel) What is the random variable $Z$ by the notation $Z =X/Y$?