I'm trying to learn about SQL Injection and how to avoid it. This is my current register php that I added escape strings. Can someone tell me if there's any other steps I should take to avoid SQL injection? Thanks.  &lt;?php  session_start();  // Set session variables to be used on profile.php page $_SESSION['email'] = $_POST['email']; $_SESSION['first_name'] = $_POST['firstname']; $_SESSION['last_name'] = $_POST['lastname'];  $first_name = $mysqli-&gt;escape_string($_POST['firstname']); $last_name = $mysqli-&gt;escape_string($_POST['lastname']); $email = $mysqli-&gt;escape_string($_POST['email']); $password = $mysqli-&gt;escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT)); $hash = $mysqli-&gt;escape_string( md5( rand(0,1000) ) ); $igname = $mysqli-&gt;escape_string($_POST['igname']); $profileurl = $mysqli-&gt;escape_string($_POST['profileurl']); $rules = $mysqli-&gt;escape_string($_POST['rules']); $username2 = $mysqli-&gt;escape_string($_POST['username']);   // Check if user with that email already exists $result = $mysqli-&gt;query("SELECT * FROM users WHERE email='$email'") or die($mysqli-&gt;error()); $result2 = $mysqli-&gt;query("SELECT * FROM users WHERE username='$username2'") or die($mysqli-&gt;error());  if ( $result-&gt;num_rows &gt; 0 ) {  $_SESSION['message'] = 'User with this email already exists!'; header("location: error.php"); exit(); }  else if ( $result2-&gt;num_rows &gt; 0 ) {  $_SESSION['message'] = 'User with this username already exists!'; header("location: error.php"); exit(); }   else {   $to = 'kielly@email.ca'; $subject = 'NEWUSER';  $message = "Someone has registered";  $headers = "From: general@email.ca\r\nReply-To: webmaster@email.com"; $mail_sent = @mail( $to, $subject, $message, $headers );  echo $mail_sent ? "Mail sent" : "Mail failed";  $sql = "INSERT INTO users (first_name, last_name, email, password, hash, igname, profileurl, readrules, admin, username) "          . "VALUES ('$first_name','$last_name','$email','$password', '$hash', '$igname', '$profileurl', '$rules', 0, '$username2')";  // Add user to the database if ( $mysqli-&gt;query($sql) ){      $_SESSION['active'] = 0; //0 until user activates their account with verify.php     $_SESSION['logged_in'] = true; // So we know the user has logged in     $_SESSION['admin'] = 0;     $_SESSION['message'] =               "Thank you for applying. Please wait while admins check over your application. You should recieve an email shortly. (Check junk folders and allow up to 5 hours for a review)";     header("location: usertest.php");   }  else {     $_SESSION['message'] = 'Registration failed!';     header("location: error.php"); } }   Should I also add prepared statements such as  $stmt = $mysqli-&gt;prepare("INSERT INTO users (first_name, last_name, email, password, hash, igname, profileurl, readrules, admin, username) VALUES (?,?,?,?,?,?,?,?,?,?)");   or is what I have above safe?
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?
I gzip directories very often at work. What I normally do is  tar -zcvf file.tar.gz /path/to/directory   Is there a way to specify the compression level here? I want to use the best compression possible even if it takes more time to compress. I'm new to the ICS os, coming from Gingerbread from another phone. The phone's quite nice and fast when I first used it, but just this morning it started exhibiting weird actions. Camera360 doesn't open up automatically when I click it, the Camera closes for no reason, Pocket restarts when an article has an image, and TTPod resets the song to the previous song on my widget in the middle of a new song I'm playing.  I checked out the ram, and and was surprised to see 500+ mb used, 0 mb available. I looked at the list of programs and I see the usual culprits like Facebook, but the ram they're using doesn't add up to 500+ mb. Yeah, I know that the whole ram indicated isn't usable by the apps, but I don't think I've done anything to warrant the 0 mb. I close my apps. There are times when there's free 4 to 5 mb, but I think that too shouldn't be the case. I tried installing Advance Task Killer, it listed less than 10 apps, killed it, still the ram is what it is above.   I did a reboot, and now it reads 300+ mb usage, 200 something free.   What can I do? How do I ensure an app's closed on ICS? I installed GoLaucher because it has a handy task killer and I can see the ram freed in an instant, but I would like to know if there's a better way to handle the RAM. Missed the MyOpenID demise; account lost forever? Is there any way to get my old account + metadata back if I have lost an account ties to MyOpenID? Please help me to answer the following problem:  Let $f(x)=x^3-3x-5\in\mathbb{Q}[x]$  Thanks More than a decade ago, I read a short story about a small group of people at the end of the world. The story was premised on some sort of mass-produced device which took ambient heat and turned it into power. The devices had been overused, and now the world was freezing.   I think the people were essentially bandits; the main character may have been a woman who lured men to her house and killed them for their body heat? There was also a strong implication that one person she had done this to was an alien who had come to warn that the devices were destroying the world.  I think the story was in a hardbound collection, and I think the collection was from the late 70's or very early 80's.  (Calling it a "short story" is just meant to distinguish it from a full novel — it may have actually been a novella or similar.) Difference between phrase and idiom What is the difference between a phrase and an idiom? I have created 50 spreadsheets for 50 students. Each spreadsheet contains 33 sheets, numbered 1 to 33, along with a couple of other sheets.  Within each of these 33 sheets, there are many protected ranges.  I accidentally protected a range that ought not to have been protected. So, with 50 students each having 33 sheets, I have over 1800 sheets to unprotected.  I want to loop through each sheet, 1 to 33, and remove protection from cell F15. Right now, I (the owner) am the only editor.  Since I'm not an actual programmer, I've clearly not done this properly.  Can someone offer a suggestion of how I can change my Google Script to make this work?  var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets = ss.getSheets();  for (var i=2; i  &lt;sheets.length; i++) {   var sheet = ss.getSheets()[i];   sheet.activate();   SpreadsheetApp.flush();   var range = sheet.getRange('F15');        var protection = range.protect().setDescription('Protected range');        var me = Session.getEffectiveUser();        protection.addEditor(me);        protection.removeEditors(protection.getEditors());        if (protection.canDomainEdit()) {          protection.remove();          } //end of if statement  } What does "\" mean in math What is meant by "object serialization"? Can you please explain it with some examples? What does \x mean in C/C++? Finding matrix $B$ is not zero matrix where $AB= 0$ The following time-frequency correspondence illustration is in .    Also a gif animation version (if the animation doesn't show, please open the following image in a new window):    This picture has so much explanatory power, and I would like to replicate it in TikZ for future use.  Here is what I came up with:  \documentclass{minimal} \usepackage{tikz}  \begin{document} \begin{tikzpicture} [x={(1cm,0.5cm)},z={(0cm,0.5cm)},y={(1cm,-0.2cm)}] \draw[-&gt;,thick,blue!90] (0,6.5,0) -- (6.2,6.5,0) node[right] {Frequency}; \draw[-&gt;,thick,red!90] (0,0,0) -- (0,6.5,0) node[below] {Time}; \draw[-&gt;,thick] (0,0,0) -- (0,0,2) node[above] {Magnitude}; \foreach \x in {0.5,1.5,2.5,3.5,4.5,5.5}{   \draw[blue!50] (\x,0,0)   \foreach \y in {0,0.02,...,6.28}{     -- ({\x},{\y},{sin(\x*\y*(157))/sqrt(2*\x)})   };   \draw[blue!90, thick] (\x,6.5,0) -- (\x,6.5,1/\x); }  \end{tikzpicture} \end{document}   This is the output so far.    I have two questions:   How to produce that red superposed sine wave of all the blue sine waves? I don't know if there is a sum function or I have to use loop yet again? How to make the camera projection in TikZ more similar to the perspective in that wikipedia illustration?   Any suggestion and tweaking of the parameters I used in the sample drawing are welcome as well.  Thanks in advance!    Update 1:  Here is a new version using tikz, more readable than the first one. Yet the superposition of the sine waves are done manually...I still don't know how to use foreach to produce a sum.  \begin{tikzpicture}[x={(1cm,0.5cm)},z={(0cm,0.5cm)},y={(1cm,-0.2cm)}] \draw[-&gt;,thick,black!70] (0,6.5,0) -- (6.2,6.5,0) node[right] {Frequency}; \draw[-&gt;,thick,black!70] (0,0,0) -- (0,6.5,0) node[below right] {Time}; \draw[-&gt;,thick] (0,0,0) -- (0,0,2) node[above] {Magnitude}; \foreach \y in {0.5,1.5,...,5.5}{ \draw [cyan!50, domain=0:2*pi,samples=200,smooth]   plot (\y,\x, {sin(4*\y*\x r)/\y }); \draw[blue, ultra thick] (\y,6.5,0) -- (\y,6.5,1/\y); } \draw [red, thick, domain=0:2*pi,samples=200,smooth]  plot (0,\x, {sin(4*0.5*\x r)/0.5 + sin(4*1.5*\x r)/1.5 + sin(4*2.5*\x r)/2.5 + sin(4*3.5*\x r)/3.5 + sin(4*4.5*\x r)/4.5 + sin(4*5.5*\x r)/5.5} ); \end{tikzpicture}   The result is as follows: Aligning equations within multline Why am I getting rounded faces when combining Edge Split and Subsurf? What's going on here? I'm trying to apply a normal edge split with a subdivision to make it look high poly with good edges. But when I applied it on this model it did this. What are good learning resources for a LaTeX beginner? Which book (free or otherwise) was the most useful to you when you started learning LaTeX?  I am frequently asked this question by friends who want to learn LaTeX, and I recommend the book which got me started, , but I feel that there might be better options around.  Also see . How can I rename many files at once? Lagrange's theorem I don't understand left coset and Lagrange's theorem... I'm working on some project so please write me anything what could help me understand it better Types of things vs. types of thing Array of zero length I am working on refactoring some old code and have found few structs containing zero length arrays (below). Warnings depressed by pragma, of course, but I've failed to create by "new" structures containing such structures (error 2233). Array 'byData' used as pointer, but why not to use pointer instead? or array of length 1? And of course, no comments were added to make me enjoy the process...  Any causes to use such thing? Any advice in refactoring those?  struct someData {    int nData;    BYTE byData[0]; }   NB It's C++, Windows XP, VS 2003 Why is ++i is l-value and i++ not?