(Solved) Why shouldn’t I use mysql_* functions in PHP?

Introduction Solution The mysql_* functions in PHP are deprecated and no longer supported. They are also vulnerable to SQL injection attacks, which can be used to gain access to sensitive data. Additionally, the mysql_* functions are not compatible with the newer versions of PHP, so using them can lead to compatibility issues. For these reasons, … Read more

(Solved) What is an undefined reference/unresolved external symbol error and how do I fix it?

Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote]. Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters … Read more

(Solved) “Notice: Undefined variable”, “Notice: Undefined index”, “Warning: Undefined array key”, and “Notice: Undefined offset” using PHP

Notice / Warning: Undefined variable From the vast wisdom of the PHP Manual: Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued … Read more

(Solved) How do I undo ‘git add’ before commit?

Undo git add for uncommitted changes with: git reset <file> That will remove the file from the current index (the “about to be committed” list) without changing anything else. To unstage all changes for all files: git reset In old versions of Git, the above commands are equivalent to git reset HEAD <file> and git … Read more

(Solved) How do I rename a local Git branch?

To rename a branch while pointed to any branch: git branch -m <oldname> <newname> To rename the current branch: git branch -m <newname> -m is short for –move. To push the local branch and reset the upstream branch: git push origin -u <newname> To delete the remote branch: git push origin –delete <oldname> To create … Read more

(Solved) How do I compare strings in Java?

== tests for reference equality (whether they are the same object). .equals() tests for value equality (whether they are logically “equal”). Objects.equals() checks for null before calling .equals() so you don’t have to (available as of JDK7, also available in Guava). Consequently, if you want to test whether two strings have the same value you … Read more

(Solved) How can I remove a specific item from an array?

Find the index of the array element you want to remove using indexOf, and then remove that index with splice. The splice() method changes the contents of an array by removing existing elements and/or adding new elements. const array = [2, 5, 9]; console.log(array); const index = array.indexOf(5); if (index > -1) { // only … Read more

(Solved) Which JSON content type do I use?

For JSON text: application/json The MIME media type for JSON text is application/json. The default encoding is UTF-8. (Source: RFC 4627) For JSONP (runnable JavaScript) with callback: application/javascript Here are some blog posts that were mentioned in the relevant comments: Why you shouldn’t use text/html for JSON Internet Explorer sometimes has issues with application/json A rather … Read more

(Solved) What does the “yield” keyword do?

To understand what yield does, you must understand what generators are. And before you can understand generators, you must understand iterables. Iterables When you create a list, you can read its items one by one. Reading its items one by one is called iteration: >>> mylist = [1, 2, 3] >>> for i in mylist: … Read more