foto's in Mysql plaatsen lukt niet
Bedankt voor de hulp die ik reeds heb gekregen maar ik blijf sukkelen...
In kort :
Door middel van 'n insertion-form creëer ik in dreamweaver 'n PHP-pagina waarmee ik data verstuur naar m'n db dit werkt.
Nu wil ik ook foto's versturen ( die gelinkt zijn aan m'n ID's van de records ) vanuit dit formpje. Dus insert ik 'n File-field waarmee ik lokaal blader om deze vervolgens te uploaden naar m'n db maar dit lukt niet... ik krijg de melding :
Notice: Undefined index: PIC in c:\easy\easyphp1-8\www\f-inject\apps\tmpkmuyjiapz2.php on line 39
Er is iets fout in de gebruikte syntax bij ')' in regel 1
M'n File-fieldje noemt nml ' PIC '...
Kan iemand me helpen ?
Dit is m'n script :
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
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
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tutorial ( NAME, JOB, LOCATION, HOBBY, PIC) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['NAME'], "text"),
GetSQLValueString($_POST['JOB'], "text"),
GetSQLValueString($_POST['LOCATION'], "text"),
GetSQLValueString($_POST['HOBBY'], "text"),
GetSQLValueString($_POST['PIC'], "file"));
mysql_select_db($database_tutorial, $tutorial);
$Result1 = mysql_query($insertSQL, $tutorial) or die(mysql_error());
$insertGoTo = "full_list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_tutorial, $tutorial);
$query_Recordset1 = "SELECT * FROM tutorial";
$Recordset1 = mysql_query($query_Recordset1, $tutorial) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_tutorial, $tutorial);
$query_Recordset2 = "SELECT distinct JOB FROM tutorial";
$Recordset2 = mysql_query($query_Recordset2, $tutorial) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tutorial ( NAME, JOB, LOCATION, HOBBY, PIC) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['NAME'], "text"),
GetSQLValueString($_POST['JOB'], "text"),
GetSQLValueString($_POST['LOCATION'], "text"),
GetSQLValueString($_POST['HOBBY'], "text"),
GetSQLValueString($_POST['PIC'], "file"));
mysql_select_db($database_tutorial, $tutorial);
$Result1 = mysql_query($insertSQL, $tutorial) or die(mysql_error());
$insertGoTo = "full_list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_tutorial, $tutorial);
$query_Recordset1 = "SELECT * FROM tutorial";
$Recordset1 = mysql_query($query_Recordset1, $tutorial) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_tutorial, $tutorial);
$query_Recordset2 = "SELECT distinct JOB FROM tutorial";
$Recordset2 = mysql_query($query_Recordset2, $tutorial) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">NAME:</td>
<td><input type="text" name="NAME" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">JOB:</td>
<td><select name="JOB">
<option value=""
Code (php)
</select> </td>
<tr valign="baseline">
<td nowrap align="right">LOCATION:</td>
<td><input type="text" name="LOCATION" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">HOBBY:</td>
<td><input type="text" name="HOBBY" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">PIC:</td>
<td><label>
<input name="PIC" type="file" id="PIC" />
</label></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
Bedankt alleszins !
Er zijn nog geen reacties op dit bericht.