Error when deleting or editing form data from database using PHP and MySQL

后端 未结 1 451
温柔的废话
温柔的废话 2021-01-29 03:31

Everything in my code seems to work just fine, except when I try to edit/delete already queried data.

Delete does nothing... and edit gives me an error shown below:

1条回答
  •  迷失自我
    2021-01-29 04:26

    First of all, use prepared Statements to prevent SQL injection. Now to your error:

    The table Employer has no column eid:

    CREATE TABLE IF NOT EXISTS `Employer` (
      `EmployerID` int(60) NOT NULL,
      `CompName` varchar(60) NOT NULL,
      `Address` varchar(20) NOT NULL,
      `Phone` int(10) NOT NULL,
      `Email` varchar(30) NOT NULL,
      `PosTitle` varchar(30) NOT NULL,
      `Description` varchar(100) NOT NULL,
      `Location` varchar(35) NOT NULL,
      `Skill1` varchar(20) NOT NULL,
      `Experience1` int(10) NOT NULL,
      `Skill2` varchar(20) NOT NULL,
      `Experience2` int(11) NOT NULL,
      `Skill3` varchar(20) NOT NULL,
      `Experience3` int(11) NOT NULL,
      `Need` varchar(15) NOT NULL,
      PRIMARY KEY (`EmployerID`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    The column name you refering is named EmployerID.

    So your statement must be delete from Employer where EmployerID=$eid.

    And because employerId is an int not a character field you do not need the single quotes arround.

    The same error is in the following select statement.

    Then you mix mysqli_* API and mysql_* (mysql_errr()). Change it to mysqli_error

    0 讨论(0)
提交回复
热议问题