One a game I am making I have a saving bug. I have an alert with the PHP message. It gives me an SQL error. The problem is obvious. That last comma before the parentheses shouldn't be there. The question is why is it there? In my code, it isn't.  This is the alert message.    The statement is like this.  &gt; $query2 = "INSERT INTO users VALUES ('$village', $power, $influence, $gold, NULL, $ore, $wood, $food, $honor, $keep, $mine, $sawmill, $farm, $barracks, $tavern, $stables, $temple, $militia, $warriors, $spearmen, $clubmen, $swordsmen, $archers, $vanguards, $legion, $crossbowmen, $knights, $mercs, $mercelites, $bandit1, $bandit2, $bandit3, '$faction', $dwellings, $dwellingscost);";   One of my theories was that the dwellingscost variable had a comma at the end. It is posted from an AJAX request. If you need some of that code to decipher just ask.
73
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?
55198
This is a bit of a strange question because I know that there should never ever be a comma after 'and.' But what if there's a parenthetical statement/clause-thing right after it? Let me demonstrate.      She spread her arms, tilted her head back, and, closing her eyes, let the sun warm her face.    Should it be:      She spread her arms, tilted her head back, and closing her eyes, let the sun warm her face.    I feel like the ,and, looks really bulky, but I also feel it's necessary to separate the statement between the commas. Help?
81423
I just edited someone's post so that it would be more readable.  Basically, I just added some line breaks and spaces into their sql code so that it now takes a reader about 5 seconds to comprehend what the query is doing instead of 50.  It was rejected on the basis that the edit was too minor.  I respect that decision in that if there's a rule that minor edits should be rejected then they were following that rule.  I am just curious to know why that is a hard rule.  Is it just to prevent having too many edits?
15937
Basically, I want to put first name &amp; surname together into $node->field_par_contact_name  But it gives me warning. (See below)   function partnership_node_presave($node) {   if($node->type == 'partnership') {     $first_name = $node->field_par_contact_first_name['und'][0]['name'];     $surname = $node->field_par_contact_surname['und'][0]['name'];      // https://drupal.org/project/field_hidden     // Hidden variable     $node->field_par_contact_name['und'][0]['value'] = $first_name. ' '. $surname;      // Warning after save: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of .../drupal-7.23/includes/entity.inc   } }   Updated, please see image:
70564
It's always drilled into us that we shouldn't use comma splices. They're bad, to be avoided and poor form.  But why? What makes the comma a faulty choice in something like this:     I never liked school, it was boring and repetitive most of the time.   It could be replaced with a semicolon, dash, period or colon and be "correct." Yet to a fair amount of people, the comma seems fine. If it weren't, it wouldn't be found so often in online forums, text messages, emails and so on.  What makes the comma between two sentences an error?
17495
I have the following code:  $countQuery = "SELECT ARTICLE_NO FROM ? WHERE upper(ARTICLE_NAME) LIKE '% ? %'"; if ($numRecords = $con-&gt;prepare($countQuery)) {     $numRecords-&gt;bind_param("ss", $table, $brand);     $numRecords-&gt;execute();     $data = $con-&gt;query($countQuery) or die(print_r($con-&gt;error));     $rowcount = mysql_num_rows($data);     $rows = getRowsByArticleSearch($query, $table, $max);     $last = ceil($rowcount/$page_rows); }   Which should work fine. However I receive the error that :  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? WHERE upper(ARTICLE_NAME) LIKE '%?%'' at line 1  If I put  SELECT ARTICLE_NO FROM AUCTIONS WHERE upper(ARTICLE_NAME) LIKE '% o %';   The query works fine. $table is defined above, and query is received from GET, and both are correct valid values. Why is this failing?  edit: changing to:  $countQuery = "SELECT ARTICLE_NO FROM AUCTIONS1 WHERE upper(ARTICLE_NAME) LIKE '% ? %'";  if ($numRecords = $con-&gt;prepare($countQuery)) {      $numRecords-&gt;bind_param("s", $query);   results in the error:   Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in C:\Program Files\EasyPHP 3.0\www\prog\get_records.php on line 38  Commands out of sync; you can't run this command now  where as   $countQuery = "SELECT ARTICLE_NO FROM AUCTIONS1 WHERE upper(ARTICLE_NAME) LIKE ?";  if ($numRecords = $con-&gt;prepare($countQuery)) {      $numRecords-&gt;bind_param("s", "%".$query."%");   results in  Fatal error: Cannot pass parameter 2 by reference in C:\Program Files\EasyPHP 3.0\www\prog\get_records.php on line 38  and lastly  $countQuery = "SELECT ARTICLE_NO FROM AUCTIONS1 WHERE upper(ARTICLE_NAME) LIKE ? ";  if ($numRecords = $con-&gt;prepare($countQuery)) {      $numRecords-&gt;bind_param("s", $query);   will give only:  Commands out of sync; you can't run this command now  Is it impossible to use a paramter for a LIKE statament?
65216
I am dissecting some code and came across this,   $sql = 'SELECT page.*, author.name AS author, updator.name AS updator '      . 'FROM '.TABLE_PREFIX.'page AS page '      . 'LEFT JOIN '.TABLE_PREFIX.'user AS author ON author.id = page.created_by_id '      . 'LEFT JOIN '.TABLE_PREFIX.'user AS updator ON updator.id = page.updated_by_id '      . 'WHERE slug = ? AND parent_id = ? AND (status_id='.Page::STATUS_REVIEWED.' OR status_id='.Page::STATUS_PUBLISHED.' OR status_id='.Page::STATUS_HIDDEN.')';   I am wondering what the "?" does in the WHERE statement.  Is it some sort of parameter holder?
84626
Consider the following sentence:     In July of 2012 Jesse informed us that she was engaged to be married   and asked if she could add her fiancée to the lease,   beginning the 15th of August 2012.   Is it any more or less correct to place a comma after the first date?     In July of 2012, Jesse informed us that she was engaged to be married   and asked if she could add her fiancée to the lease,   beginning the 15th of August 2012.   Assuming one is no more correct than the other, does this change the meaning of the sentence, or is it pure style?   Bonus question: Word tells me that it's improper to place a comma after the "August" at the end of the sentence. I've always been taught that a comma should be used to separate the year from the rest of the date. Was I taught wrong, or is Word lying to me?
27610
I'm receiving the following warnings when I use mysql_query() in my modules:  mysql_query(): A link to the server could not be established in ...... on line 6  If I use db_query() instead, it works fine.   The code is a simple SELECT query with no special characters or variables. The actual query is mysql_query("SELECT * FROM custom_nodify WHERE nid = 345");  I should mention that this happens with ANY mysql_query(), not just the one above.  Any suggestions as to why this doesn't work?
56732
Should you always type a comma after &quot;therefore&quot;,&quot;however&quot; etc. in the beginning of a sentence? Also, when these (and similar) words are used in the middle of a sentence, should there be a comma or semi-colon before and after the word?  Therefore, he must be killed! That man is revolting, however, some find him attractive.  Sorry for the lousy examples. I couldn't think of any better.
52955
I've seen this convention pretty much everywhere, and, at times, it comes close to driving me nuts:  &lt;?php //The loop ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt;     &lt;?php the_content(); ?&gt; &lt;?php endwhile; // end of the loop. ?&gt;   Where the &lt;?php and closing ?&gt; are on every single line, even if there is no intervening HTML code.    My question is: Why?  Why include all these extra tags?      To me, it seems this convention adds a significant amount of clutter to code, is annoying to follow in the first place, and adds that many more places to accidentally leave out an opening or closing tag.  NOTE  This is code pulled from the Twenty-Twelve theme, the example given by WordPress.
85770
I just spotted someone use \newcommand* in an answer and realised that I'd never quite sorted out in my head what the star (asterisk) was there for.  (This one is practically impossible to search for on the internet so this is a good place to record the answer!)
82615
On PHP 5.3.13/MySQL 5.5.21 the following code doesn't work:  if($check_custom_fields_form!=1){     $sql = "CREATE TABLE IF NOT EXISTS ". $table_custom_fields_form ." (                 `form_name` longtext NOT NULL,                 `field_id` bigint(20) NOT NULL,                 FOREIGN KEY (`field_id`) REFERENCES $table_custom_fields (`ID`) ON DELETE CASCADE ON UPDATE CASCADE     ) CHARACTER SET utf8 COLLATE utf8_general_ci";     dbDelta($sql); } if($check_subscribe_cat!=1){     $sql = "CREATE TABLE IF NOT EXISTS ". $table_subscribe_cat ." (                 `subscribe_id` bigint(20) NOT NULL,                 `cat_id` bigint(20) NOT NULL,                 FOREIGN KEY (`subscribe_id`) REFERENCES ".$wpdb-&gt;prefix."tgt_subscription (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,                 FOREIGN KEY (`cat_id`) REFERENCES ".$wpdb-&gt;prefix."terms (`term_id`) ON DELETE CASCADE ON UPDATE CASCADE     ) CHARACTER SET utf8 COLLATE utf8_general_ci";     dbDelta($sql);  }   The  suggested a downgrade to MySQL 5.1.37 (no, thanks) or the following update:  if($check_custom_fields_form!=1){         $sql = "CREATE TABLE IF NOT EXISTS ". $table_custom_fields_form ." (                     `form_name` longtext NOT NULL,                     `field_id` bigint(20) NOT NULL,                     KEY(field_id)         ) CHARACTER SET utf8 COLLATE utf8_general_ci";         dbDelta($sql);     } if($check_subscribe_cat!=1){       $sql = "CREATE TABLE IF NOT EXISTS ". $table_subscribe_cat ." (                   `subscribe_id` bigint(20) NOT NULL,                   `cat_id` bigint(20) NOT NULL,                   KEY(subscribe_id),                   KEY(cat_id)       ) CHARACTER SET utf8 COLLATE utf8_general_ci";       dbDelta($sql);    }   Which seems like a rather dirty way to work around the problem (no cascading deletes/updates). Therefore:   Do I really have to live with that ? Is it true that dbDelta only works with foreign key in a 3 year old MySQL version?
23315
I have this sentence on my resume:     Develop the front-end of a platform using HTML, CSS, and Bootstrap to connect people and systems   Is there a comma after Bootstrap? I wanted to elaborate on the reason for building the application rather than simply listing the programming languages I used.
3565
After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL.  That is:  SELECT `id`, `name`, `anotherfield` ... -- vs -- SELECT id, name, anotherfield ...
112694
What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field?    Field with value "00345ABC" would need to return "345ABC".
4650
I was looking at an exercise where it asked the following:  $$\begin{array}{ccc} p&amp;q&amp;p\rightarrow q \\ T&amp;T&amp;T \\ &amp;\ldots \end{array}$$  So, for the third column, I just put $T$ which was correct but I didn't understand what $\rightarrow$ meant. I have seen $\implies$ but I haven't the arrow. Are they the same thing?  Thanks a bunch!