billledouble

Inscris le 05/08/2009 à 15:46
  • Signature
    bill
  • Nombre de sujets
    2
  • Nombre de messages
    7
  • Nombre de commentaires
    Aucun
  • Nombre de news
    Aucune
  • Niveau en PHP
    Débutant

Ses derniers sujets sur les forums

billledouble
le 12/08/2009 à 11:47
MYSQL : Erreur de syntaxe près de ' à la ligne 1
Bonjour,

Cela fait deux heures que je cherche à corriger cette erreur qui apparaît lorsque je tente d'enregistrer les données saisies dans la BDD correspondante, mais ne trouve pas :

Erreur de syntaxe près de 'div) VALUES ('test', 'test', 'test', 'test', 'test', 'test', 'te' à la ligne 1

Merci d'avance pour vos suggestions avisées,

Bill

Le code

<?php
//connection au serveur & sélection de la base de données

require_once('Connections/gestion_if.php');

//récupération des valeurs des champs

$famprogc = $_POST['famprogc'];
$perprogc = $_POST['perprogc'];
$nomprogc = $_POST['nomprogc'];
$dotaprogc = $_POST['dotaprogc'];
$natprogc = $_POST['natprogc'];
$bailprogc = $_POST['bailprogc'];
$docsprogc = $_POST['docsprogc'];
$conteuprogc = $_POST['conteuprogc'];
$contnatprogc = $_POST['contnatprogc'];
$objprogc = $_POST['objprogc'];
$nomprog = $_POST['nomprog'];
$dotaprog = $_POST['dotaprog'];
$natprog = $_POST['natprog'];
$docsprog = $_POST['docsprog'];
$conteuprog = $_POST['conteuprog'];
$contnatprog = $_POST['contnatprog'];
$objprog = $_POST['objprog'];
$nosprog = $_POST['nosprog'];
$nomsprog = $_POST['nomsprog'];
$objsprog = $_POST['objsprog'];
$dotasprog = $_POST['dotasprog'];
$noobjmsp = $_POST['noobjmsp'];
$nomobjmsp = $_POST['nomobjmsp'];
$objobjmsp = $_POST['objobjmsp'];
$dotaobjmsp = $_POST['dotaobjmsp'];
$nodomsm = $_POST['nodomsm'];
$nomdomsm = $_POST['nomdomsm'];
$objdomsm = $_POST['objdomsm'];
$dotadomsm = $_POST['dotadomsm'];
$ratprog = $_POST['ratprog'];
$aireint = $_POST['aireint'];
$paysel = $_POST['paysel'];
$regel = $_POST['regel'];
$depel = $_POST['depel'];
$parteu = $_POST['parteu'];
$critel = $_POST['critel'];
$nomact = $_POST['nomact'];
$themact = $_POST['themact'];
$sthemact = $_POST['sthemact'];
$objcontact = $_POST['objcontact'];
$typeactel = $_POST['typeactel'];
$motcle = $_POST['motcle'];
$depelact = $_POST['depelact'];
$depinelact = $_POST['depinelact'];
$critqualact = $_POST['critqualact'];
$dureproj = $_POST['dureproj'];
$benpot = $_POST['benpot'];
$montsubv = $_POST['montsubv'];
$tauxsubv = $_POST['tauxsubv'];
$appelproj = $_POST['appelproj'];
$carappproj = $_POST['carappproj'];
$datelimcand = $_POST['datelimcand'];
$lieudepdos = $_POST['lieudepdos'];
$docs = $_POST['docs'];
$div = $_POST['div'];

//création & exécution de la requête SQL

$sql = "INSERT INTO gestion_if (famprogc, perprogc, nomprogc, dotaprogc, natprogc, bailprogc, docsprogc, conteuprogc, contnatprogc, objprogc, nomprog, dotaprog, natprog, docsprog, conteuprog, contnatprog, objprog, nosprog, nomsprog, objsprog, dotasprog, noobjmsp, nomobjmsp, objobjmsp, dotaobjmsp, nodomsm, nomdomsm, objdomsm, dotadomsm, ratprog, aireint, paysel, regel, depel, parteu, critel, nomact, themact, sthemact, objcontact, typeactel, motcle, depelact, depinelact, critqualact, dureproj, benpot, montsubv, tauxsubv, appelproj, carappproj, datelimcand, lieudepdos, docs, div) VALUES ('$famprogc', '$perprogc', '$nomprogc', '$dotaprogc', '$natprogc', '$bailprogc', '$docsprogc', '$conteuprogc', '$contnatprogc', '$objprogc', '$nomprog', '$dotaprog', '$natprog', '$docsprog', '$conteuprog', '$contnatprog', '$objprog', '$nosprog', '$nomsprog', '$objsprog', '$dotasprog', '$noobjmsp', '$nomobjmsp', '$objobjmsp', '$dotaobjmsp', '$nodomsm', '$nomdomsm', '$objdomsm', '$dotadomsm', '$ratprog', '$aireint', '$paysel', '$regel', '$depel', '$parteu', '$critel', '$nomact', '$themact', '$sthemact', '$objcontact', '$typeactel', '$motcle', '$depelact', '$depinelact', '$critqualact', '$dureproj', '$benpot', '$montsubv', '$tauxsubv', '$appelproj', '$carappproj', '$datelimcand', '$lieudepdos', '$docs', '$div')";

$result = mysql_query($sql) or die(mysql_error());
echo "Nouvelle ligne de financement insérée dans la base de données !";
?>
bill
billledouble
le 05/08/2009 à 15:56
Champ select multiple - problème insertion valeur dans BDD MySql
Bonjour,

J'ai consulté pendant plus de 4 heures différents forums mais n'ai pas trouvé de réponse à mon problème que je vous expose ci-après :

J'ai créé un formulaire me permettant d'insérer des éléments dans une base de données MYSQL.

J'ai un problème avec un des champs: un champ select multiple. Alors qu'en testant le formulaire je choisis avec CTRL deux valeurs et que j'envoie mon formulaire, aucune valeur n'est inscrite dans le champ correspondant 'aireint' de la base de données.

Merci d'avance de vos suggestions.

Bill

CODE DE MON FORMULAIRE REALISE AVEC DREAMWEAVER - VOIR CHAMP SELECT

<?php header('Content-Type: text/html; charset=utf-8'); ?>
<?php include_once("fckeditor/fckeditor.php") ; ?>
<?php require_once('Connections/gestion_if.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form_1")) {
$insertSQL = sprintf("INSERT INTO saisie_if (id_saisie, nomsousif, docs2, natsousif, pointeusif, pointnatsif, aireint) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_saisie'], "int"),
GetSQLValueString($_POST['nomsousif'], "text"),
GetSQLValueString($_POST['docs2'], "text"),
GetSQLValueString($_POST['natsousif'], "text"),
GetSQLValueString($_POST['pointeusif'], "text"),
GetSQLValueString($_POST['pointnatsif'], "text"),
GetSQLValueString($_POST['aireint'], "text");

mysql_select_db($database_gestion_if, $gestion_if);
$Result1 = mysql_query($insertSQL, $gestion_if) or die(mysql_error());

$insertGoTo = "message_1.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_gestion_if, $gestion_if);
$query_lstaireint = "SELECT * FROM lstaireint";
$lstaireint = mysql_query($query_lstaireint, $gestion_if) or die(mysql_error());
$row_lstaireint = mysql_fetch_assoc($lstaireint);
$totalRows_lstaireint = mysql_num_rows($lstaireint);

?>
<!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=utf-8" />
<title>Saisie IF</title>
<style type="text/css">
<!--
.Style3 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: x-small; }
.Style4 {font-size: x-small}
.Style5 {font-family: Geneva, Arial, Helvetica, sans-serif}
-->
</style>
</head>

<body>
<label>
</label>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form_1" target="_self" id="form_1">


<table width="100%" border="0">
<tr>
<th width="28%" align="left" valign="top" scope="row"><span class="Style5">Niveau 1</span></th>
<td width="4%">&nbsp;</td>
<td width="68%">&nbsp;</td>
</tr>
<tr>
<th width="28%" align="left" valign="top" scope="row">&nbsp;</th>
<td width="4%">&nbsp;</td>
<td width="68%">&nbsp;</td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.1 Nom du sous-programme</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top"><?php
$oFCKeditor = new FCKeditor('nomsousif') ;
$oFCKeditor->BasePath = './FCKeditor/';

//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';

$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?></td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.2 Documents</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top"><?php
$oFCKeditor = new FCKeditor('docs2') ;
$oFCKeditor->BasePath = './FCKeditor/';

//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';

$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?></td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.3 Nature du sous-programme</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top"><?php
$oFCKeditor = new FCKeditor('natsousif') ;
$oFCKeditor->BasePath = './FCKeditor/';

//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';

$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?></td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.4 Point d’information européen</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top"><?php
$oFCKeditor = new FCKeditor('pointeusif') ;
$oFCKeditor->BasePath = './FCKeditor/';

//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';

$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?></td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.5 Point d’information européen</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top"><?php
$oFCKeditor = new FCKeditor('pointnatsif') ;
$oFCKeditor->BasePath = './FCKeditor/';

//set the EnterMode to "br" (overwrites the default configuration from fckconfig.js)
$oFCKeditor->Config['EnterMode'] = 'br';

$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?></td>
</tr>
<tr valign="baseline">
<th align="left" valign="top" class="Style3" scope="row">2.6 Aire d’intervention</th>
<td align="left" valign="top" nowrap="nowrap"><img src="images/Info.png" alt="" width="25" height="25" /></td>
<td align="left" valign="top">

// CHAMP SELECTION EN QUESTION

<label>
<select name="aireint" size="4" id="aireint">
<?php
do {
?>
<option value="<?php echo $row_lstaireint['id_aireint']?>"><?php echo $row_lstaireint['aireint']?></option>
<?php
} while ($row_lstaireint = mysql_fetch_assoc($lstaireint));
$rows = mysql_num_rows($lstaireint);
if($rows > 0) {
mysql_data_seek($lstaireint, 0);
$row_lstaireint = mysql_fetch_assoc($lstaireint);
}
?>
</select>
</label></td>
</tr>
<tr valign="baseline">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th align="left" valign="top" scope="row"></th>
<td>&nbsp;</td>
<td><input type="submit" name="Enregistrer" id="Enregistrer" value="Enregistrer" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form_1" />
</form>
</body>
</html>
<?php
mysql_free_result($lstaireint);

?>
bill
LoadingChargement en cours