Undefined index
Ik weet dat er al een topic of 5 erover bestaan. maar ik word er niet wijzer van.
Ik ben nu al een tijdje bezig om deze error uit te hallen. maar ik blijf hem krijgen.
Quote:
Notice: Undefined index: first_name in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 61
Notice: Undefined index: lastname_name in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 62
Notice: Undefined index: adres in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 63
Notice: Undefined index: adres_nr in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 64
Notice: Undefined index: adres_zip in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 65
Notice: Undefined index: adres_city in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 66
Notice: Undefined index: details in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 67
Notice: Undefined index: category in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 68
Notice: Undefined index: subcategory in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 69
Notice: Undefined index: details in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 70
Notice: Undefined index: lastname_name in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 62
Notice: Undefined index: adres in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 63
Notice: Undefined index: adres_nr in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 64
Notice: Undefined index: adres_zip in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 65
Notice: Undefined index: adres_city in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 66
Notice: Undefined index: details in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 67
Notice: Undefined index: category in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 68
Notice: Undefined index: subcategory in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 69
Notice: Undefined index: details in /www/zxq.net/a/c/c/accoint/htdocs/x2/admin/modules/contact/contact_edit.php on line 70
dit is mijn script (alle dat stuk toch)
Quote:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// Gather this contact's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT * FROM contacts WHERE id='$targetID' LIMIT 1");
$contactCount = mysql_num_rows($sql); // count the output amount
if ($contactCount > 0) {
while($row = mysql_fetch_array($sql)){
$first_name = mysql_real_escape_string($_POST['first_name']);
$last_name = mysql_real_escape_string($_POST['lastname_name']);
$adres = mysql_real_escape_string($_POST['adres']);
$adres_nr = mysql_real_escape_string($_POST['adres_nr']);
$adres_zip = mysql_real_escape_string($_POST['adres_zip']);
$adres_city = mysql_real_escape_string($_POST['adres_city']);
$details = mysql_real_escape_string($_POST['details']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
$details = mysql_real_escape_string($_POST['details']);
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "Sorry";
exit();
}
}
?>
// Gather this contact's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT * FROM contacts WHERE id='$targetID' LIMIT 1");
$contactCount = mysql_num_rows($sql); // count the output amount
if ($contactCount > 0) {
while($row = mysql_fetch_array($sql)){
$first_name = mysql_real_escape_string($_POST['first_name']);
$last_name = mysql_real_escape_string($_POST['lastname_name']);
$adres = mysql_real_escape_string($_POST['adres']);
$adres_nr = mysql_real_escape_string($_POST['adres_nr']);
$adres_zip = mysql_real_escape_string($_POST['adres_zip']);
$adres_city = mysql_real_escape_string($_POST['adres_city']);
$details = mysql_real_escape_string($_POST['details']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
$details = mysql_real_escape_string($_POST['details']);
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "Sorry";
exit();
}
}
?>
Waar loopt het mis ? alvast bedankt !!
Gewijzigd op 27/11/2011 21:56:10 door Tom Vanhecke
Lijn 9 t/m 19. Waarom gebruik je mysql_real_escape_string() op een moment dat het niet nodig is?
Quote:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// Gather this contact's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT * FROM contacts WHERE id='$targetID' LIMIT 1");
$contactCount = mysql_num_rows($sql); // count the output amount
if ($contactCount > 0) {
while($row = mysql_fetch_array($sql)){
$first_name = $row["first_name"];
$last_name = $row["last_name"];
$adres = $row["adres"];
$adres_nr = $row["adres_nr"];
$adres_zip = $row["adres_zip"];
$adres_city = $row["adres_city"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$details = $row["details"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "Sorry";
exit();
}
}
?>
// Gather this contact's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT * FROM contacts WHERE id='$targetID' LIMIT 1");
$contactCount = mysql_num_rows($sql); // count the output amount
if ($contactCount > 0) {
while($row = mysql_fetch_array($sql)){
$first_name = $row["first_name"];
$last_name = $row["last_name"];
$adres = $row["adres"];
$adres_nr = $row["adres_nr"];
$adres_zip = $row["adres_zip"];
$adres_city = $row["adres_city"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$details = $row["details"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "Sorry";
exit();
}
}
?>
bug fix
Regel 9 t/m 18 blijven overbodig. Waarom gebruik je niet gewoon de data uit $row?
ik sta open voor verbetering. maar zet er wel een woordje uitleg bij ....
Het is onzinnig... Met = overschrijf je variabelen. En waarom zou je ze dan dus kopiëren zodat je dezelfde waarde vanbij. $row["first_name"] ook in $first_name hebt?
En aanvulling op Aar: Wat is het nut? Je doet helemaal niks met de gegevens.
Waar is de controle op geldigheid van pid?
Gebruik geen * maar selecteer het veld/de velden die je nodig hebt.
Variabelen buiten quotes.
Foutafhandeling mist bij je query.
Geen idee welke tut je volgt, maar lijkt me verstandig om verder te kijken ;-)