Jump to content

Recommended Posts

Hi Guys,

 

on the site i am developing i have noticed after a database insertion is made, mysql insert another row (but only the id increments by 1)

 

if i insert:

 

id---name---age---country

1 ---Graham---28---Scotland

 

right after this will be:

 

2 ---blank---blank---blank

 

i checked the inserts carefully it all seems fine, then tried LIMIT 1, with the INSERT INTO but that didn't work, any ideas on what this could be?

 

thanks guys

 

Graham

 

Hi Mate,

 

here it is:

 

     // data outwith th eisset...////////////////////////////////////////////////////////
     $query = "SELECT * FROM `membership` WHERE `username`='$member'";
     $result = mysql_query($query) or die (mysql_error());
     $row = mysql_fetch_array($result) or die (mysql_error());          
     $id = $row['id'];
     $poster_name = $row['username'];
     
     ####################################################################################     
     if (isset($_POST['submit'])) {
     
     // the posts/files...///////////////////////////////////////////////////////////////
     $file_name = $_POST['file_name'];
     $nfo = $_FILES['nfo']['name'];
     $nzb = $_FILES['nzb']['name'];
     $category = stripslashes($_POST['category']);
     $description = stripslashes($_POST['description']);
     
     // the posts/files...///////////////////////////////////////////////////////////////
     $max_file_size = 2000000; 
     $file_accepted = array("text/xml","application/octet-stream");
     
     // also grab the nzb size...////////////////////////////////////////////////////////
     $nzb_size = $_FILES['nzb']['size'];
     
     // Rename the nzb with random digits.../////////////////////////////////////////////
     $random_number = rand(00000000,99999999);
     $renamed_nzb = $random_number.".".substr($_FILES["nzb"]["name"],strtolower(strlen($_FILES["nzb"]["name"]))-3,3);
                            
     // empty fields...//////////////////////////////////////////////////////////////////
     if(empty($file_name)) {
     
       echo "<br /><b><font color=\"red\"/>Error:</font> Sorry, No Filename! <a href=\"upload_nzb.php\" />Go Back</a></b><br /><br />";
       include("includes/footer.php");
       exit;
     
     }
     
     // empty fields...//////////////////////////////////////////////////////////////////
     if(empty($nzb)) {
     
       echo "<br /><b><font color=\"red\"/>Error:</font> Sorry, No NZB Or RAR Uploaded! <a href=\"upload_nzb.php\" />Go Back</a></b><br /><br />";
       include("includes/footer.php");
       exit;
     
     }

     // empty fields...//////////////////////////////////////////////////////////////////
     if(empty($description)) {
     
       echo "<br /><b><font color=\"red\"/>Error:</font> Sorry, No Description Added! <a href=\"upload_nzb.php\" />Go Back</a></b><br /><br />";
       include("includes/footer.php");
       exit;
     
     }
     
     // 1) Validate for byte size.../////////////////////////////////////////////////////
     if ($_FILES['nzb']['size'] > $max_file_size) {
     
       echo "<br />Sorry, That File Is To Big To Be Uploaded.<br /><br />";
       include("includes/footer.php");
       exit;
       
     }

     // 2) Validate for file type.../////////////////////////////////////////////////////
     if (!in_array($_FILES['nzb']['type'], $file_accepted)) {
     
       echo "<br /><font color=\"red\"/>Error:</font> Sorry, That File Doesn't Look Like An <b>.nzb</b> Please Check Again.<br /><br />";
       include("includes/footer.php");
       exit;
       
     } 
     
     ## NZB #############################################################################
     
     // upload folder...//////////////////////////////////////////////////////////////////
     $uploadpath = "uploaded_nzbs/"; 
     $uploadpath = $uploadpath.$renamed_nzb; 
     
     //Store it in the database...////////////////////////////////////////////////////////
     !move_uploaded_file($_FILES["nzb"]["tmp_name"], $uploadpath); 
     
     ## NZB #############################################################################
     
     ## NFO #############################################################################     

     // upload location for the nfo...///////////////////////////////////////////////////
     $uploadpath2 = "uploaded_nfos/"; 
     $uploadpath2 = $uploadpath2.$nfo; 
     
     !move_uploaded_file($_FILES["nfo"]["tmp_name"], $uploadpath2); 
     
     ## NFO ############################################################################# 
      
     $filename = $nfo;
     $content = file_get_contents("uploaded_nfos/$filename");     
     $nfo_for_mysql = mysql_real_escape_string($content);
          
     // insert the info...///////////////////////////////////////////////////////////////
     $query2 = "INSERT INTO `uploaded_nzbs` (`poster_name`,`file_name`,`nzb_file`,`nzb_size`,`category`,`description`,`nfo`,`nfo_name`,`date_added`)
                VALUES ('$poster_name','$file_name','$renamed_nzb','$nzb_size','$category','$description','$nfo_for_mysql','$nfo',now())";
     $result2 = mysql_query($query2);

 

cheers

 

Graham

 

cheers

 

Graham

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.