foto's in Mysql plaatsen lukt niet

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Fred

Fred

19/05/2007 18:09:00
Quote Anchor link
Hello allemaal !
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)
PHP script in nieuw venster Selecteer het PHP script
1
<?php require_once('../Connections/tutorial.php'); ?>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?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);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $editFormAction; ?>
" 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">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
do {  
?>

<option value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Recordset2['JOB']?>
"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php if (!(strcmp($row_Recordset2['JOB'], $row_Recordset1['ID']))) {echo "SELECTED";} ?>
>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Recordset2['JOB']?>
</option>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
?>

</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">&nbsp;</td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>


Bedankt alleszins !
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.