dongmoyu0336 2013-03-24 03:57
浏览 19

如何在PHP中一次编辑多个值

I'm trying to edit many columns at one time. I have a lot of fields that I want users to be able to edit. I'm not sure exactly what I'm doing incorrectly. Any help would be greatly appreciated. It states that There was a problem with your mySQL query please contact technical support with the following information:

       <?php 
       $dbserver = "";
       $dblogin = "";
       $dbpassword = "";
       $dbname = "";

       $con = mysqli_connect("$dbserver","$dblogin","$dbpassword","$dbname");
       if (!$con)
       {
       die('Could not connect to the mySQL server please contact technical 
       support with the following information: ' . mysqli_connect_errno());
       }

       $organization = mysqli_real_escape_string($_POST['organization']);
       $firstname = mysqli_real_escape_string($_POST['firstname']);
       $lastname = mysqli_real_escape_string($_POST['lastname']);
       $rank = mysqli_real_escape_string($_POST['rank']);
       $branch= mysqli_real_escape_string($_POST['branch']);
       $gender= mysqli_real_escape_string($_POST['gender']);
       $emailaddress = mysqli_real_escape_string($_POST['emailaddress']);
       $jobtitle = mysqli_real_escape_string($_POST['jobtitle']);
       $company = mysqli_real_escape_string($_POST['company']);
       $businessphone = mysqli_real_escape_string($_POST['businessphone']);
       $homephone = mysqli_real_escape_string($_POST['homephone']);
       $mobilephone = mysqli_real_escape_string($_POST['mobilephone']);
       $faxnumber = mysqli_real_escape_string($_POST['faxnumber']);
       $address = mysqli_real_escape_string($_POST['address']);
       $city = mysqli_real_escape_string($_POST['city']);
       $state = mysqli_real_escape_string($_POST['state']);
       $zippostal = mysqli_real_escape_string($_POST['zippostal']);
       $country = mysqli_real_escape_string($_POST['country']);
       $notes = mysqli_real_escape_string($_POST['notes']);
       $donorid = mysqli_real_escape_string($_POST['donorid']);

       // make the query a variable so we can print out if it fails
       $query = "UPDATE donors SET organization = '$organization', firstname =         
       '$firstname', lastname = '$lastname', rank = '$rank', branch = '$branch', 
       gender = '$gender', emailaddress = '$emailaddress', jobtitle = '$jobtitle', 
       company = '$company', businessphone = '$businessphone', homephone = 
       '$homephone', mobilephone = '$mobilephone', faxnumber = '$faxnumber', address = 
       '$address', city = '$city', state = '$state', zippostal = '$zippostal', country 
       = '$country', notes = '$notes', donorid = '$donorid' WHERE donorid = 
       '$donorid'";

       $sql = mysqli_query($con,$query) or die('There was a problem with your mySQL   
       query please contact technical support with the following information: ' .  
       mysqli_error());

       // troubleshooting for development only     
       if(mysqli_affected_rows($sql) < 1){
       die('There was a problem with your mySQL query : ' . $query);}

       mysqli_close($con);
        header( 'Location: http://localhost/moddonor.php' ) ;
        ?>
  • 写回答

3条回答 默认 最新

  • duandie0921 2013-03-24 04:01
    关注

    You didnt mention whats the error but,

    I think you must wrap the values using single quote ('), for example

    set organization = $organization

    becomes

    set organization = '$organization'

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题