I need to delete user from a mySQL row. My "Delete" button works only on the first page, but when I change page it no longer works, . This is the code I use for delete:  $(document).ready(function() {   $('#large').dataTable({     "sPaginationType": "full_numbers",     "iDisplayLength": 5,     "aoColumnDefs": [{       "bSortable": false,       "aTargets": [-1]     }]   });    $(".lnk").click(function() {     if (confirm("This user will be deleted. Press ok to confirm.")) {       $.ajax({         type: "POST",         url: "deactivate-user.php",         data: {           "user": $(this).attr('id')         },         dataType: 'HTML',         success: function(data) {           if (data == "Error") {             $("#msg").html("Error occured while removing user! Please try after some time.");             $("#msg").addClass("red-box");             $("#msg").css("display", "block");           } else {             $("#msg").html("User has been removed successfully.");             $("#msg").addClass("green-box");             $("#msg").css("display", "block");             $("#main-table").html(data);           }         }       });     }   }); });   &lt;td&gt;   &lt;a href="add-credit.php?user=&lt;?php echo $row['user_id']; ?&gt;" name="credit" class="btn btn-primary credit"&gt;Credit&lt;/a&gt;   &lt;a id="&lt;?php echo $row['user_id']; ?&gt;" class="btn btn-danger lnk"&gt;Delete&lt;/a&gt; &lt;/td&gt;    Where is my error?
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
50374
I have a form with only a select element and no submit button. Upon change, I issue an ajax call to retrieve the details of the selected Project. Everything works as expected, however after I leave the page, I see the error "An illegal choice has been detected. Please contact the site administrator."  I only get the error if I change the select input. Ex. if I navigate to:     Home->Projects->Home   I don't see the error on the last Home page. If i navigate to:     Home->Projects(change select input)->Home   I see the error on the last Home page.  Here is my module code:  class ExpeditionController extends ControllerBase {   public $client;    public function __construct() {     $this-&gt;client = \Drupal::service('http_client');   }     public function listProjects() {     $select_form = \Drupal::formBuilder()-&gt;getForm('Drupal\myModule\Form\ExpeditionSelectForm');     // Remove the submit button.     unset($select_form['actions']['submit']);      $result = $this-&gt;client-&gt;get('myRESTService', ['Accept' =&gt; 'application/json']);     $expeditions = json_decode($result-&gt;getBody());      foreach ($expeditions as $value) {       $select_form['expeditions']['#options'][$value-&gt;{'expedition'}-&gt;{'expeditionId'}] = $this-&gt;t($value-&gt;{'expedition'}-&gt;{'expeditionTitle'});     }      return array(       '#theme' =&gt; 'myModule_expeditions',       '#form' =&gt; $select_form,     );   }    public function expeditionDetail($form, $form_state) {     $expedition = [];     $response = new AjaxResponse();     if ($form['expeditions']['#value'] != "") {        $client = \Drupal::service('http_client');       $result = $client-&gt;get(         'myService' . $form['expeditions']['#value'],         ['Accept' =&gt; 'application/json']       );       $expedition = json_decode($result-&gt;getBody());     }      $response-&gt;addCommand(new HtmlCommand(       '#expeditionDetail',       array(         '#theme' =&gt; 'myModule_expeditions_detail',         '#expedition' =&gt; $expedition,       )     ));      return $response;   }    public function deploymentDetail($project_id, $deployment_id) {     $result = $this-&gt;client-&gt;get(       'myService' . $project_id . '/' . $deployment_id,       ['Accept' =&gt; 'application/json']     );      return array(       '#theme' =&gt; 'myModule_deployment_detail',       '#deployment' =&gt; json_decode($result-&gt;getBody()),     );    } }  class ExpeditionSelectForm extends ConfigFormBase {   /**    * {@inheritdoc}    */   public function getFormId() {     return 'myModule_expeditions';   }    /**    * {@inheritdoc}    */   public function buildForm(array $form, FormStateInterface $form_state) {     $form['expeditions'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose Project'),       '#empty_option' =&gt; $this-&gt;t('Select a project'),       '#default_value' =&gt; '',       '#ajax' =&gt; [         'callback' =&gt; 'Drupal\myModule\Controller\ExpeditionController::expeditionDetail',       ],     );      return parent::buildForm($form, $form_state);   }    /**    * Gets the configuration names that will be editable.    *    * @return array    *   An array of configuration object names that are editable if called in    *   conjunction with the trait's config() method.    */   protected function getEditableConfigNames() {     // TODO: Implement getEditableConfigNames() method.     return [];   } }
103134
I have come to the conclusion that my PHP installation and my MySQL installation are not getting along; I’m working on making my first web page that uses MySQL for content, but after two days, man pages, online documentation, and dozens of tutorials, I just can’t get the PHP/MySQL part to work.  I have an established home web server (I am the only admin/user) that runs Apache and hosts my web pages.  I have MySQL installed, and was able to create and query a database through Terminal.  I have PHP installed, and can use echo to print text to the document.  When I work with MySQL however, everything changes…  I have a page that contains initialization stuff in .  contains a few paragraphs of hardcoded HTML and then PHP code to access MySQL.  When I first loaded the page, all that resulted was a blank page.  I commented out the PHP section and reloaded to confirm that the plain HTML still worked, which it did.  Therefore, some part of PHP was keeping any of the page from ever loading.    To begin troubleshooting my code, I left all of the PHP code commented except the following code for the server connection, which is adapted from several different tutorials:  &lt;? echo("&lt;p&gt;PHP is working&lt;/p&gt;");  $ses = mysql_connect("localhost","username","password"); if(!$ses){  echo("&lt;p&gt;Connection to content server failed.&lt;/p&gt;");  exit(); } echo("&lt;p&gt;Database Connected&lt;/p&gt;"); ?&gt;   When the page is loaded, the beginning HTML loads in addition to a paragraph reading “PHP is working” but neither the failure or success message appear.  I removed the If structure from the code - so that only two echos and the mysql_connect remained – and got the same result.    It seems that the mysql_connect feature is causing the server to stop loading the code when it is run, but I’m out of ideas for how to fix it.  For the record: I’ve modified the php.ini file to include the “connection = msql.so” line, and I’m using MySQL 5.5, Apache 2.2.22, PHP 5.3.10, Ubuntu 12.04.  Also, both my router and modem have been configured to forward port 3306 to the server – though I don’t see how that should be necessary – and my MySQL username and password have been triple checked and are identical to the ones that I use successfully in Terminal.  What am I missing?
81999
What's the most efficient way to select the last n number of rows in a table using mySQL? The table contains millions of rows, and at any given time I don't know how large the table is (it is constantly growing). The table does have a column that is automatically incremented and used as a unique identifier for each row.
77647
I'm writing a web app using Twitter Bootstrap with PHP on server side. My app makes regular ajax requests via jQuery and i want to disable certain parts of the UI until the server completes processing and hands back the control to Client-Side.  I wonder what would be best practices for the same?
61928
A little bit of context:  I'm using the jQuery Validation plugin to validate a sign-up form. I now want to implement an ajax call to check whether the user name is available in the system, and I want to make this ajax call only if the userName value is a valid one as per the rules set in $(form).validate();  I want something like:  $("#userName").keyup(function () {     if ($("#userName").isValid()) {         //make ajax called     } });   I searched the documentation but i couldn't identify the solution to my problem.
26688
I need to delete some rows from one large table. The rows to delete shouldn't be in another table, example:  DELETE FROM LargeTable WHERE id IS NOT IN (SELECT DISTINCT foreign_id from EvenLargerTable)  but my server can't handle such blunt query, because there are almost a million records in the LargeTable and few million records in the EvenLargerTable  How can I solve it?
19982
As title, possible? I have by accident deleted another record due to my ugly html interface in FireFox. The bad thing is this record delete is a root folder which the program automatically cascade delete everything :(
107747
Please bear with me because I am new to utilizing Wordpress PHP this way. I have the following script:  &lt;div id="content"&gt; &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;          // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;              // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                  echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 78 ) {                 break;             }                     endwhile;     else :         // no rows found     endif;     ?&gt;     &lt;/div&gt;     &lt;div id="loading-image" style="display: none;"&gt;&lt;/div&gt;     &lt;div id="part2"&gt;&lt;/div&gt;     &lt;script&gt;          var w = $(window);         window.onscroll = function(ev) {             if ($(document).height() - w.height() == w.scrollTop()) {                  $('#loading-image').show();                 $.ajax({                     url: "&lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php",                     cache: false,                     success: function(result){                       $("#part2").html(result);                     },                     complete: function(){                       $('#loading-image').hide();                     }                 });             }         };     &lt;/script&gt;   The the Php page that I am trying to load pretty much contains the same code . It just stops after loading 200 fields.   &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;         // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;             // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                 echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 200 ){               break;             }                      endwhile;     else :         // no rows found     endif; ?&gt;   I don't know why the php page (post-2.php) is not loading. The strange thing is that when I replace &lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php with a test html page &lt;?php echo get_stylesheet_directory_uri();?&gt;/test.html The test page (test.html) loads.  I have to say that I looked on in my console using the console tab of my browser added console.log(); to view any errors and I'm not getting any errors. I also looked in my networked tag to ensure that post-2.php loaded properly and I'm not getting errors. My goal is to find out why my PHP page isn't loading  ***** Update ***** I'm being told to use $post_id but I've never used it. Does anyone have a working example of this? Would it be similar to if( have_rows('repeat_field', $post_id) ): or if( have_rows('repeat_field', 55612) ): ?
85030
I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:  import MySQLdb  conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname") cursor=conn.cursor()  cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100") cursor.execute("SELECT Co_num FROM compinfo WHERE ID=100") results = cursor.fetchall()  for row in results:     print row[0]  print "Number of rows updated: %d" % cursor.rowcount  cursor.close() conn.close()   The output I get when I run this program is:     4Number of rows updated: 1   It seems like it's working but if I query the database from the MySQL command line interface (CLI) I find that it was not updated at all. However, if from the CLI I enter UPDATE compinfo SET Co_num=4 WHERE ID=100; the database is updated as expected.  What is my problem? I'm running Python 2.5.2 with MySQL 5.1.30 on a Windows box.
110595
I am trying to save multiple values from a textarea to a database table.  I use the following code, but I feel it is the wrong way.   foreach ($user_emails as $key =&gt; $value) {   $insert_banned_emails = db_insert('banned_users');   $insert_banned_emails     -&gt;fields(array(       'email' =&gt; $value,     ))     -&gt;execute(); }   Is there a different way for achieving the same result?
40938
After I posted this question, I found a similar post that seemed to answer it: . I'll leave this in place for now, as I am not sure how to mark my own question as a duplicate  In attempting to debug a SOQL query error, I encountered a strange behavior with Database.query and bind variables. Specifically, when I run this code:  String userQuery = 'SELECT Id FROM User'; if (true) {     List&lt;String&gt; firstNames = new List&lt;String&gt;{'James','Joe'};     userQuery += ' WHERE FirstName IN :firstNames'; } Database.query(userQuery);   the Database.query statement executes with no errors, despite the fact that the variable firstNames does not exist in its context. However, when I add an else clause:  String userQuery = 'SELECT Id FROM User'; if (true) {     List&lt;String&gt; firstNames = new List&lt;String&gt;{'James','Joe'};     userQuery += ' WHERE FirstName IN :firstNames'; } else {     List&lt;String&gt; firstNames; } Database.query(userQuery);   I receive a null object reference exception. It seems like Salesforce is checking to see if the variable is only declared once beforehand and, if so, uses its value in the context it was declared. This seems strange to me, so I was wondering if anybody here has any insight into what is going on under the hood.
94609
I'm working at an app which would make a POST ajax request to a PHP script on my server. The script would query the database and return a row of records, as an array. (One array for each row, containing elements such as id, title, etc). I then want to use json_encode() to encode this array, and pass it back to the javascript which will use it to display the records.  1) How can I return the JSON encoded string to the javascript? 2) How will the javascript loop through the rows and access their fields?
26532
I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load.  How could I go about doing this?
34548
I'm trying to make a class that will execute any one of a number of stored procedures with any amount of variables  Im using php and mysqli   My class enumerates an array and constructs a string based on the number of elements if any giving something like this CALL spTestLogin(?,?) for example I now need to bind the input from my array using somethin like this:  $stmt->bind_param($this->paramTypes,$this->paramValues);//paramValues is my array   Then if that works I can work on getting my results  Any ideas
86789
I don't have this kind of ID in my table, still MySQL is giving me a result.  This same result is giving when i place in my php code.
38310
Given the following classes and controller action method:  public School {   public Int32 ID { get; set; }   publig String Name { get; set; }   public Address Address { get; set; } }  public class Address {   public string Street1 { get; set; }   public string City { get; set; }   public String ZipCode { get; set; }   public String State { get; set; }   public String Country { get; set; } }  [Authorize(Roles = "SchoolEditor")] [AcceptVerbs(HttpVerbs.Post)] public SchoolResponse Edit(Int32 id, FormCollection form) {   School school = GetSchoolFromRepository(id);    UpdateModel(school, form);    return new SchoolResponse() { School = school }; }   And the following form:  &lt;form method="post"&gt;   School: &lt;%= Html.TextBox("Name") %&gt;&lt;br /&gt;   Street: &lt;%= Html.TextBox("Address.Street") %&gt;&lt;br /&gt;   City:  &lt;%= Html.TextBox("Address.City") %&gt;&lt;br /&gt;   Zip Code: &lt;%= Html.TextBox("Address.ZipCode") %&gt;&lt;br /&gt;   Sate: &lt;select id="Address.State"&gt;&lt;/select&gt;&lt;br /&gt;   Country: &lt;select id="Address.Country"&gt;&lt;/select&gt;&lt;br /&gt; &lt;/form&gt;   I am able to update both the School instance and the Address member of the school.  This is quite nice!  Thank you ASP.NET MVC team!  However, how do I use jQuery to select the drop down list so that I can pre-fill it?  I realize that I could do this server side but there will be other dynamic elements on the page that affect the list.  The following is what I have so far, and it does not work as the selectors don't seem to match the IDs:  $(function() {   $.getJSON("/Location/GetCountryList", null, function(data) {     $("#Address.Country").fillSelect(data);   });   $("#Address.Country").change(function() {     $.getJSON("/Location/GetRegionsForCountry", { country: $(this).val() }, function(data) {       $("#Address.State").fillSelect(data);     });   }); });