如何在PHP中修复未定义的索引和未定义的变量? [英] How to fix both undefined index and undefined variable in PHP?

查看:90
本文介绍了如何在PHP中修复未定义的索引和未定义的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是php的新手。当我点击提交按钮显示提交成功时,我创建了多个表单。我创建了多个查询,用于将数据插入到不同的五个表中。



创建数据库连接时在...中显示错误为未定义的变量。在我修复该问题后,我显示了另一个错误未定义的索引在......。然后我修复了它,但再次显示未定义的变量在......错误。 br />


所以我使用下面的代码来修复未定义的索引和未定义的变量错误。但是现在当我提交数据时表格没有很好地更新。正确填充了两个表。(contact_details表,extra_curricular_activity表)。一个表没有两个字段(academic_details表,Z_Score字段和A_Grade1字段)。其他两个表都是空的所有字段。但是在单击提交按钮时添加新行。(课程详情表,personal_details表)



数据库和错误字段的空字段是相同的......所以如何修复这个



我尝试了什么:



这是我用来修复未定义索引的代码未定义的变量错误



I'm new for the php. I created a multiple forms when i click submit button show "submitted successfully".And I create multi query for insert data to different five tables.

when creating database connection I have displayed error as "undefined variable in...".After I fix that Problem I have displayed another error "undefined index in...".then I fixed it but again shows "undefined variable in..." error.

So I used following code for fix both undefined index and undefined variable error.but now when I submit data that tables are not update well. two tables are correctly filled.(contact_details table,extra_curricular_activity table).One table filled without two fields(academic_details table,Z_Score field and A_Grade1 field).other two tables are empty all fields.but add new row when the click submit button.(course details table,personal_details table)

That empty fields of the database and error fields are the same..so how can I fixed this

What I have tried:

this is the code i was use to fix both undefined index and undefined variable error

$profile_picture = isset( $_POST['profile_picture'] )? $_POST['profile_picture']: false;
$student_id = isset( $_POST['student_id'] )? $_POST['student_id']: false;
$admitted_date = isset( $_POST['admitted_date'] )? $_POST['admitted_date']: false;
$academic_year = isset( $_POST['academic_year'] )? $_POST['academic_year']: false;
$course = isset( $_POST['course'] )? $_POST['course']: false;
$first_name = isset( $_POST['first_name'] )? $_POST['first_name']: false;
$middle_name = isset( $_POST['middle_name'] )? $_POST['middle_name']: false;
$last_name = isset( $_POST['last_name'] )? $_POST['last_name']: false;
$dob = isset( $_POST['dob'] )? $_POST['dob']: false;
$gender = isset( $_POST['gender'] )? $_POST['gender']: false;
$nic = isset( $_POST['nic'] )? $_POST['nic']: false;
$nationality = isset( $_POST['nationality'] )? $_POST['nationality']: false;
$religion = isset( $_POST['religion'] )? $_POST['religion']: false;
$race = isset( $_POST['race'] )? $_POST['race']: false;
$a_grade1 = isset( $_POST['a_grade1'] )? $_POST['a_grade1']: false;
$z_score = isset( $_POST['z_score'] )? $_POST['z_score']: false;

推荐答案

profile_picture = isset(
profile_picture = isset(


_POST [' profile_picture'])?
_POST['profile_picture'] )?


_POST [' profile_picture']:false;
_POST['profile_picture']: false;


这篇关于如何在PHP中修复未定义的索引和未定义的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆