Ingevulde data komt niet in database
waar ga ik de fout in? zoek al dagen, maar bij de submit knop van de index optie wordt ik voorzien van alle code uit [qoute3]om die reden wordt er ook geen data in mijn database ingevoerd.
alvast bedankt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?php
$localhost = "localhost";
$dbuser = "root";
$dbpass = "pw";
$dbname ="vracht";
$connect = mysql_connect($localhost, $dbuser, $dbpass);
mysql_select_db("$dbname", $connect);
?>
$localhost = "localhost";
$dbuser = "root";
$dbpass = "pw";
$dbname ="vracht";
$connect = mysql_connect($localhost, $dbuser, $dbpass);
mysql_select_db("$dbname", $connect);
?>
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
<head>
</head>
<meta http-equiv="content-type" content = "text/html; charset=utf-8" />
<title></title>
<body>
<form method="post" action="regprocess.php" >
<table width="300" border="0">
<tr>
<td>Idnumber</td>
<td><input type= "text" name="Idnumber" /></td>
</tr>
<tr>
<td>Size</td>
<td><input type= "text" name="Size" />
</tr>
<tr>
<td>Diameter</td>
<td><input type= "text" name="Diameter" />
</tr>
<tr>
<td>Tips</td>
<td><input type= "text" name="Tips" />
</tr>
<tr>
<td>Nr._Of_bulb</td>
<td><input type= "text" name="Nr._of_bulb" />
</tr>
<tr>
<td>Cu.ft.</td>
<td><input type= "text" name="Cu.ft" />
</tr>
<tr>
<td>Length</td>
<td><input type= "text" name="Lenght" />
</tr>
<tr>
<td>Height</td>
<td><input type= "text" name="Height" />
</tr>
<tr>
<td>Width</td>
<td><input type= "text" name="Width" />
</tr>
<tr>
<td>CBM</td>
<td><input type= "text" name="CBM" />
</tr>
<tr>
<td>G.W.</td>
<td><input type= "text" name="G.W." />
</tr>
<tr>
<td>N.W.</td>
<td><input type= "text" name="N.W." />
</tr>
<tr>
<td>Stand</td>
<td><input type= "text" name="Stand" />
</tr>
<tr>
<td>Pack</td>
<td><input type= "text" name="Pack" />
</tr>
<tr>
<td>Warehouse</td>
<td><input type= "text" name="Warehouse" />
</tr>
<tr>
<td>FOB_Dollar </td>
<td><input type= "text" name="FOB_Dollar" />
</tr>
<tr>
<td>Barcode</td>
<td><input type= "text" name="Barcode" />
</tr>
<tr>
<td></td>
<td><input type= "Submit" name="Submit" />
</tr>
</table>
</form>
</body>
</html>
<head>
</head>
<meta http-equiv="content-type" content = "text/html; charset=utf-8" />
<title></title>
<body>
<form method="post" action="regprocess.php" >
<table width="300" border="0">
<tr>
<td>Idnumber</td>
<td><input type= "text" name="Idnumber" /></td>
</tr>
<tr>
<td>Size</td>
<td><input type= "text" name="Size" />
</tr>
<tr>
<td>Diameter</td>
<td><input type= "text" name="Diameter" />
</tr>
<tr>
<td>Tips</td>
<td><input type= "text" name="Tips" />
</tr>
<tr>
<td>Nr._Of_bulb</td>
<td><input type= "text" name="Nr._of_bulb" />
</tr>
<tr>
<td>Cu.ft.</td>
<td><input type= "text" name="Cu.ft" />
</tr>
<tr>
<td>Length</td>
<td><input type= "text" name="Lenght" />
</tr>
<tr>
<td>Height</td>
<td><input type= "text" name="Height" />
</tr>
<tr>
<td>Width</td>
<td><input type= "text" name="Width" />
</tr>
<tr>
<td>CBM</td>
<td><input type= "text" name="CBM" />
</tr>
<tr>
<td>G.W.</td>
<td><input type= "text" name="G.W." />
</tr>
<tr>
<td>N.W.</td>
<td><input type= "text" name="N.W." />
</tr>
<tr>
<td>Stand</td>
<td><input type= "text" name="Stand" />
</tr>
<tr>
<td>Pack</td>
<td><input type= "text" name="Pack" />
</tr>
<tr>
<td>Warehouse</td>
<td><input type= "text" name="Warehouse" />
</tr>
<tr>
<td>FOB_Dollar </td>
<td><input type= "text" name="FOB_Dollar" />
</tr>
<tr>
<td>Barcode</td>
<td><input type= "text" name="Barcode" />
</tr>
<tr>
<td></td>
<td><input type= "Submit" name="Submit" />
</tr>
</table>
</form>
</body>
</html>
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
include"config.php";
$Idnumber = $_POST['Idnumber'];
$Size = $_POST['Size'];
$Diameter = $_POST['Diameter'];
$Tips = $_POST['Tips'];
$Nr._Of_bulb = $_POST['Nr._Of_bulb'];
$Cu.ft = $_POST['Cu.ft'];
$Lenght = $_POST['Length'];
$Height = $_POST['Hight'];
$Width = $_POST['Width'];
$CBM = $_POST['CBM'];
$G.W. = $_POST['G.W.'];
$N.W. = $_POST['N.W.'];
$Stand = $_POST['Stand'];
$Pack = $_POST['Pack'];
$Warehouse = $_POST['Warehouse'];
$FOB_Dollar = $_POST['FOB_Dollar'];
$Barcode = $_POST['Barcode'];
$insert = 'INSERT INTO 'vracht'(Idnumber, Size, Diameter, Tips, Nr._of_bulb, Cu.ft, Length, Height, Width, CBM, G.W., N.W., Stand, Pack, Warehouse, FOB_Dollar, Barcode)
VALUES("'.Idnumber.'", "'.Size.'", "'.Diameter.'", "'.Tips.'", "'.Nr._of_bulb.'", "'.Cu.fr.'", "'.Lenght.'", "'.Height.'", "'.Width.'", "'.CBM.'", "'.G.W..'", "'.N,W..'", "'.Stand.'", "'.Pack.'", "'.Warehouse.'", "'.FOB_Dollar.'", "'.Barcode.'")';
Mysql_query($insert);
?>
include"config.php";
$Idnumber = $_POST['Idnumber'];
$Size = $_POST['Size'];
$Diameter = $_POST['Diameter'];
$Tips = $_POST['Tips'];
$Nr._Of_bulb = $_POST['Nr._Of_bulb'];
$Cu.ft = $_POST['Cu.ft'];
$Lenght = $_POST['Length'];
$Height = $_POST['Hight'];
$Width = $_POST['Width'];
$CBM = $_POST['CBM'];
$G.W. = $_POST['G.W.'];
$N.W. = $_POST['N.W.'];
$Stand = $_POST['Stand'];
$Pack = $_POST['Pack'];
$Warehouse = $_POST['Warehouse'];
$FOB_Dollar = $_POST['FOB_Dollar'];
$Barcode = $_POST['Barcode'];
$insert = 'INSERT INTO 'vracht'(Idnumber, Size, Diameter, Tips, Nr._of_bulb, Cu.ft, Length, Height, Width, CBM, G.W., N.W., Stand, Pack, Warehouse, FOB_Dollar, Barcode)
VALUES("'.Idnumber.'", "'.Size.'", "'.Diameter.'", "'.Tips.'", "'.Nr._of_bulb.'", "'.Cu.fr.'", "'.Lenght.'", "'.Height.'", "'.Width.'", "'.CBM.'", "'.G.W..'", "'.N,W..'", "'.Stand.'", "'.Pack.'", "'.Warehouse.'", "'.FOB_Dollar.'", "'.Barcode.'")';
Mysql_query($insert);
?>
Edit:
Code-tags i.p.v. Quote-tags gebruikt...
Gewijzigd op 04/09/2013 19:24:23 door - Ariën -
Even wat tips:
- Het is onnodig om variabelen te overschrijven (codeblok 3, regel 4 t/m 20. Alle $_POST[] variabelen heb je al beschikbaar, die kan je gewoon in je query gebruiken.
- Beveilig de $_POST[] variabelen tegen SQL-injection door mysql_real_escape_string te gebruiken.
- Gebruik in je query als eerste en laatste de double-quotes ", voor je VALUES welke een string zijn moet je een single-quote ' gebruiken.
- Pas goede foutafhandeling toe op je query, en te kijken of deze zich goed resulteert of een false terug geeft.
- Oriënteer je eens op MySQLi of PDO, gezien de functies van mysql() de laan uit zullen gaan op langere termijn.
Gewijzigd op 30/08/2013 15:25:23 door - Ariën -
Punten in kolomnamen van je database gebruiken?
Tja, dat is vragen om problemen. Haal die punten eruit. Nooit, nooit, nooit, andere tekens gebruiken dan letters (eventueel cijfers) en underscores. Andere karakters leveren alleen maar problemen op.
Toevoeging op 30/08/2013 15:31:00:
En dan ga je hier overigens ook nog eens de fout in:
Ik neem aan dat vracht gewoon de naam is van je tabel, dan moet dat natuurlijk niet tussen quotes staan.
Gewijzigd op 30/08/2013 15:31:17 door Erwin H
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?php
include("config.php");
$localhost = "localhost";
$dbuser = "root";
$dbpass = "test123";
$dbname = "vracht";
$connect = mysql_connect($localhost, $dbuser, $dbpass);
mysql_select_db($dbname, $connect);
?>
include("config.php");
$localhost = "localhost";
$dbuser = "root";
$dbpass = "test123";
$dbname = "vracht";
$connect = mysql_connect($localhost, $dbuser, $dbpass);
mysql_select_db($dbname, $connect);
?>
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$notify = "";
$ProductID = mysql_escape_string($_POST['ProductID']);
$Size = mysql_escape_string($_POST['Size']);
$Diameter = mysql_escape_string($_POST['Diameter']);
$Tips = mysql_escape_string($_POST['Tips']);
$Nr_Of_bulb = mysql_escape_string($_POST['Nr_Of_bulb']);
$Cu_ft = mysql_escape_string($_POST['Cu_ft']);
$Length = mysql_escape_string($_POST['Length']);
$Height = mysql_escape_string($_POST["Height"]);
$Width = mysql_escape_string($_POST['Width']);
$CBM = mysql_escape_string($_POST['CBM']);
$G_W = mysql_escape_string($_POST['G_W']);
$N_W = mysql_escape_string($_POST['N_W']);
$Stand = mysql_escape_string($_POST['Stand']);
$Pack = mysql_escape_string($_POST['Pack']);
$Warehouse = mysql_escape_string($_POST['Warehouse']);
$FOB_Dollar = mysql_escape_string($_POST['FOB_Dollar']);
$Barcode = mysql_escape_string($_POST['Barcode']);
if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
// send the data to the database
include("archive/file.inc");
$connection = mysql_connect($localhost, $dbuser, $dbpass)
or die("Error: ".mysql_error());
$db = mysql_select_db($dbname, $connection)
or die("Error: ".mysql_error());
$create = "INSERT INTO artikel(ID, ProductID, Size, Diameter, Tips, Nr_Of_bulb, Cu_ft, Length, Height, Width,
CBM, G_W, N_W, Stand, Pack, Warehouse, FOB_Dollar, Barcode)
VALUES('$ID', '$ProductID','$Size','$Diameter','$Tips','$Nr_Of_bulb','$Cu_ft','$Length','$Height','$Width','$CBM','$G_W','$N_W','$Stand','$Pack'
,'$Warehouse','$FOB_Dollar','$Barcode')";
$result = mysql_query($create)
or die("Error: ".mysql_error());
mysql_close($connection);
?>
$notify = "";
$ProductID = mysql_escape_string($_POST['ProductID']);
$Size = mysql_escape_string($_POST['Size']);
$Diameter = mysql_escape_string($_POST['Diameter']);
$Tips = mysql_escape_string($_POST['Tips']);
$Nr_Of_bulb = mysql_escape_string($_POST['Nr_Of_bulb']);
$Cu_ft = mysql_escape_string($_POST['Cu_ft']);
$Length = mysql_escape_string($_POST['Length']);
$Height = mysql_escape_string($_POST["Height"]);
$Width = mysql_escape_string($_POST['Width']);
$CBM = mysql_escape_string($_POST['CBM']);
$G_W = mysql_escape_string($_POST['G_W']);
$N_W = mysql_escape_string($_POST['N_W']);
$Stand = mysql_escape_string($_POST['Stand']);
$Pack = mysql_escape_string($_POST['Pack']);
$Warehouse = mysql_escape_string($_POST['Warehouse']);
$FOB_Dollar = mysql_escape_string($_POST['FOB_Dollar']);
$Barcode = mysql_escape_string($_POST['Barcode']);
if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
// send the data to the database
include("archive/file.inc");
$connection = mysql_connect($localhost, $dbuser, $dbpass)
or die("Error: ".mysql_error());
$db = mysql_select_db($dbname, $connection)
or die("Error: ".mysql_error());
$create = "INSERT INTO artikel(ID, ProductID, Size, Diameter, Tips, Nr_Of_bulb, Cu_ft, Length, Height, Width,
CBM, G_W, N_W, Stand, Pack, Warehouse, FOB_Dollar, Barcode)
VALUES('$ID', '$ProductID','$Size','$Diameter','$Tips','$Nr_Of_bulb','$Cu_ft','$Length','$Height','$Width','$CBM','$G_W','$N_W','$Stand','$Pack'
,'$Warehouse','$FOB_Dollar','$Barcode')";
$result = mysql_query($create)
or die("Error: ".mysql_error());
mysql_close($connection);
?>
Gewijzigd op 04/09/2013 18:00:29 door axl vd
Zou je een betere titel kunnen bedenken?
Je kunt dit bericht niet wijzigen. Dit kan de volgende oorzaken hebben:
Je hebt het meer dan 2 dagen geleden geplaatst.
Een moderator heeft je bericht gewijzigd.
Dit topic is gesloten.
Dit bericht is niet van jou.
gebruik voor height eens single-quotes, en kijk eens of het veld-type wel klopt.
- Aar - op 30/08/2013 15:24:42:
- Het is onnodig om variabelen te overschrijven (codeblok 3, regel 4 t/m 20. Alle $_POST[] variabelen heb je al beschikbaar, die kan je gewoon in je query gebruiken.
- Beveilig de $_POST[] variabelen tegen SQL-injection door mysql_real_escape_string te gebruiken.
- Beveilig de $_POST[] variabelen tegen SQL-injection door mysql_real_escape_string te gebruiken.
Doe je nu bijna goed. Je maakt nog steeds (onnodig) variabelen aan.
mysql_real_escape_string gebruik je doorgaans _in_ een query, niet op de wijze die jij nu doet.
ja 'single-quotes' had allang geprobeerd, maar thanks tho
Nog niet opgelost? Wat voor waarde wil je erin plaatsen? En wat voor type is dat veld?
deleted include("archive/file.inc");
table verwijderd, opnieuw de table er tussen gezet. weer op "varchar 255"
vervolgens:
line error op 49, dus:
en VALUES('ID ipv $ID