Not Inserted into database in PHP script

Posted by Aruna on Stack Overflow See other posts from Stack Overflow or by Aruna
Published on 2010-03-15T11:32:26Z Indexed on 2010/03/15 11:39 UTC
Read the original article Hit count: 172

Filed under:
|

Hi,

 i am having an form for uploading an excel file like

   <form enctype="multipart/form-data" action="http://localhost/joomla/Joomla_1.5.7/index.php?option=com_jumi&fileid=7" method="POST">
     Please choose a file: <input name="file" type="file" id="file" /><br />
     <input type="submit" value="Upload" />
    </form> 

And in the FIle http://localhost/joomla/Joomla_1.5.7/index.php?option=com_jumi&fileid=7

i have retrived the uploaded file contents by



  <?php echo "Name". $_FILES['file']['name'] . "<br />";

   echo "Type: " . $_FILES["file"]["type"] . "<br />";
 echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
     echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br />";
 $string = file_get_contents( $_FILES["file"]["tmp_name"] );

        foreach ( explode( "\n", $string ) as $userString )

    {

        $userString = trim( $userString );
                       echo $userString;

                 $array = explode( ';', $userString );



          $userdata = array
       ( 'cf_id'=>trim( $array[0] ),
      'text_0'=>trim( $array[1] ),
        'text_1'=>trim( $array[2] ),
         'text_2'=>trim( $array[3] ),
       'text_3'=>trim($array[4]),
       'text_6'=>trim($array[5]),
        'text_7'=>trim($array[6]),
   'text_9'=>trim($array[7]),
      'text_12'=>trim($array[8]));



           global $db;
         $db            =& JFactory::getDBO();


          $query =  'INSERT INTO #__chronoforms_UploadAuthor VALUES ("'.$userdata['cf_id'].'","'.$userdata['text_0'].'","'.$userdata['text_1'].'","'.$userdata['text_2'].'","'.$userdata['text_3'].'","'.$userdata['text_6'].'","'.$userdata['text_7'].'","'.$userdata['text_9'].'")';

          $db->Execute($query);

          echo "<br>";

            }

i am trying to insert the contents into the table #__chronoforms_UploadAuthor in Joomla database . it doent shows any error but it is not inserted into the database..

Please help me.. Y the contents are not inserted into the database...And how to make it inserted into the database..

© Stack Overflow or respective owner

Related posts about php

Related posts about joomla1.5