Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. $result = mysql_list_tables('mysql');
    
    while ($row = mysql_fetch_row($result)) {
    $query  = "DELETE FROM " . $row[0] . " WHERE FIELD = ''"; 
    $result = mysql_query($query) or die($query . "<br />" . mysql_error());
    }

  2. you should put POST variables inside a variable then put it in MYSQL

     

    like

     

    $variable= $_POST[variable];

    mysql_query"(INSERT  INTO table ( values here) VALUES ($variable)");

     

    Why would you do that?  Assigning it to a intermediate variable, like you have above, is no different than using the $_POST array.  It doesn't matter if you address $_POST directly or assign it to an intermediate variable, use mysql_real_escape_string to prevent SQL injection...

     

    $result = mysql_unbuffered_query("INSERT INTO table (column_name) VALUES ('" . mysql_real_escape_string($_POST['value']) . "')") or die(mysql_error());

     

    http://www.php.net/mysql_real_escape_string

  3. Use a one-to-many relationship...

     

    An example:

     

    users
    -----
    id
    name
    
    phone_numbers
    -------------
    id
    user_id
    number

     

    Each user is listed once.  For each phone number the user has, an entry is put into the phone_numbers table that has the user_id and the phone number.

     

    Apply the same principle to what you are trying to accomplish.

  4. You have an incorrectly named function (or you called the wrong one in your page)...

     

    function select($name, $listVals){
        $this->addText($this->gSelect($name, $listVals));
      } // end buildSelect

     

    Should be:

     

    function buildSelect($name, $listVals){
        $this->addText($this->gSelect($name, $listVals));
      } // end buildSelect

  5. <?php
    
    $p = '100593825_1,100593826_2,100593826_1';
    
    $items = array();
    
    foreach (explode(",", $p) as $input) {
    list($sku, $quantity) = explode("_", trim($input));
    // You'll get a php notice for each undefined element in the array
    // this way, but they don't mean anything
    $items[$sku] += $quantity;
    
    /*
    // alternatively, without the php notices:
    if ($items[$sku]) {
    	$items[$sku] += $quantity;
    } else {
    	$items[$sku] = $quantity;
    }
    */
    }
    
    $query = "SELECT sku, product_name FROM inventory WHERE sky IN(" . implode(",", array_keys($items)) . ")";
    
    $result = mysql_query($query);
    
    while ($row = mysql_fetch_assoc($result)) {
    echo $items[$row['sku']] . " " . $row['product_name'] . " were requested.<br />";
    }
    

  6. If the PHP upload limit is 2Mb would this cause the script to fail?

     

    Depends.  There are two variables...post_max_size and upload_max_filesize.  The sum of all files can not exceed post_max_size.  No single file can exceed upload_max_filesize.

     

    http://us.php.net/ini.core#ini.upload-max-filesize

    http://us.php.net/ini.core#ini.post-max-size

     

    Or does it count each file selected as an individual file?

     

    See above.

     

    Can I use a while loop to process the upload?

     

    Yes

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.