我知道有很多关于SE的文章"警告:缺少参数2"问题,虽然我似乎无法找到答案(即使在多次查看所有其他问题之后)。
第一个错误集:http://i.stack.imgur.com/HTySO.png
第二个错误集:http://i.stack.imgur.com/wDwxm.png
(我尝试发布为SE图像,但由于我是新手,它不会让我)
这是我目前获得20次的两个错误(我有20个不同的数据库字段,它是"个人资料"部分)。
我花了两个半小时的时间来试图弄清楚它为什么不起作用,但我一无所知。
addProfile.php:
<?php
include('../includes/functions.php');
if(isset($_POST['submit'])) {
if(isset($_POST['profile_name'])) {
addProfile($_POST['profile_name']);
} else {
echo "Please Enter A Profile Name!";
include('manage_settings.php');
}
if(isset($_POST['profile_description'])) {
addProfile($_POST['profile_description']);
} else {
echo "Please Enter A Profile Description!";
include('manage_settings.php');
}
if(isset($_POST['first_name'])) {
addProfile($_POST['first_name']);
}
if(isset($_POST['last_name'])) {
addProfile($_POST['last_name']);
}
if(isset($_POST['company'])) {
addProfile($_POST['company']);
}
if(isset($_POST['office_phone'])) {
addProfile($_POST['office_phone']);
}
if(isset($_POST['cell_phone'])) {
addProfile($_POST['cell_phone']);
}
if(isset($_POST['fax_num'])) {
addProfile($_POST['fax_num']);
}
if(isset($_POST['email_addr'])) {
addProfile($_POST['email_addr']);
}
if(isset($_POST['website'])) {
addProfile($_POST['website']);
}
if(isset($_POST['motto'])) {
addProfile($_POST['motto']);
}
if(isset($_POST['street_addr'])) {
addProfile($_POST['street_addr']);
}
if(isset($_POST['city'])) {
addProfile($_POST['city']);
}
if(isset($_POST['state'])) {
addProfile($_POST['state']);
}
if(isset($_POST['zip'])) {
addProfile($_POST['zip']);
}
if(isset($_POST['country'])) {
addProfile($_POST['country']);
}
if(isset($_POST['facebook_url'])) {
addProfile($_POST['facebook_url']);
}
if(isset($_POST['places_url'])) {
addProfile($_POST['places_url']);
}
if(isset($_POST['twitter_url'])) {
addProfile($_POST['twitter_url']);
}
if(isset($_POST['linkedin_url'])) {
addProfile($_POST['linkedin_url']);
}
} else {
header("Location: manage_settings.php");
}
?>
functions.php:
<?php
include('connect.php');
function getProfiles() {
$query = mysql_query("SELECT * FROM global_profiles") or die(mysql_error());
if(mysql_num_rows($query) == 0) {
echo "<center><h3><b><u>No Profiles Currently Available</u></b></h3></center>";
} else {
while($profile = mysql_fetch_assoc($query)) {
echo "<tr><td><input type=\"checkbox\" /></td><td>" . $profile['profile_name'] . "</td><td><a href=\"#\" title=\"title\">Coming Soon</a></td><td>" . $profile['profile_description'] . "</td><td>" . $profile['pid'] . "</td><td><a href=\"edit.php?pid=" . $profile['pid'] . "\" title=\"Edit\"><img src=\"images/pencil.png\" alt=\"Edit\" /></a> <a href=\"delete.php?pid=" . $profile['pid'] . "\" title=\"Delete\"><img src=\"images/cross.png\" alt=\"Delete\" /></a> <a href=\"duplicate.php?pid=" . $profile['pid'] . "\" title=\"Duplicate\"><img src=\"images/hammer_screwdriver.png\" alt=\"Duplicate\" /></a></td></tr>";
}
}
}
function deleteProfile($pid) {
$pid = (int) $pid;
mysql_query("DELETE FROM global_profiles WHERE pid = '$pid'") or die(mysql_error());
header("Location: manage_settings.php");
}
function addProfile($pid, $profile_name, $profile_description, $first_name, $last_name, $company, $office_phone, $cell_phone, $fax_num, $email_addr, $website, $motto, $city, $state, $zip, $country, $facebook_url, $places_url, $twitter_url, $linkedin_url) {
$query = mysql_query("INSERT INTO global_profiles VALUES(null,'$profile_name','$profile_description','$first_name','$last_name','$company','$office_phone','$cell_phone','$fax_num','$email_addr','$website','$motto','$city','$state','$zip','$country','$facebook_url','$places_url','$twitter_url','$linkedin_url')") or die(mysql_error());
}
?>
我尝试做的事情基本上是&#34;保存&#34;我的数据库的新信息。我已经能够通过phpMyAdmin手动将其添加到数据库中,然后在我的管理区域内显示信息。
非常感谢任何帮助!
答案 0 :(得分:0)
将addProfile()
修改为:
function addProfile($post) {
// Here check wether you have certain post array key set and add it to query
}
并将其用作:
if(isset($_POST['profile_name'])) {
addProfile($_POST);
}