dongpo2002 2019-06-04 13:51
浏览 179

如何动态插入mysql

I have done a program who show a list of youtube video and when I click on one of them, I open a bootstrap modal. There I want input some data to video_time_table. It is working whithout problems, but I need to input the video_id_nr from the video_name_table into the video_time_table to link them together. It working OK on my first try. Next try it stop on the insert_timestamp.php. The data is inserted into the database but the page is empty and only show message "Successfully inserted". After some 10 minutes it working correct one time again.

Here is a link to the original code: http://technotip.com/2208/insert-data-into-mysql-jquery-ajax-php/

I have tried to close the page and reopen it, but still it not working until I have waited about 10 minutes. Then when I reload de pages it work one time again.

This is the input of the video_id_nr in the modal :

    <div class="form-group">
    <label>Video id number</label>
    <input type="text" class="form-control" name="video_id_nr" value='<? 
    php echo $videoId ?>'>
    </div> 

This is the database code: insert_timestamp.php where the program is trapped second try. It start working 10 minutes later.

   <?php require_once('connVideoAlbum.php');
   mysql_select_db($database_connKomponent, $connKomponent);    
   $startime = $_POST['event_start_time'];
   $stoptime = $_POST['event_stop_time']; 
   $info = $_POST['event_info'];
   $video_id_nr = $_POST['video_id_nr']; 
   $squery ="INSERT INTO video_time_table(event_start_time,
   event_stop_time,event_info,video_id_nr) 
   VALUES ('$startime','$stoptime','$info','$video_id_nr')";
   if(mysql_query($squery, $connKomponent)){
   echo "Succsessfully inserted";
   }else{ 
   echo "Insertion failed";
   }       
   mysql_close();
   ?>

This is the javascript:

    $("#sub").click( function() {
    $.post( $("#myForm").attr("action"),
    $("#myForm :input").serializeArray(),
    function(info){ $("#result").html(info);
    });
    clearInput();
    });

    $("#myForm").submit( function() {
    return false;    
    });
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效