Bonjour,
Je suis en train de developper un petit site en PHP/MySQL. N'etant pas un specialiste mais un peu familiarise avec la programmation, j'utilise Dreamweaver (d'ou ce code ...)
A l'insertion d'un enregistrement dans la base de donnees, j'ai un mechant message que je copie ici et qui peut etre vu par ceux qui se donneront la peine de remplir le formulaire de l'adresse :
http://www.job.edendesign-tm.com/formular_inscriere.php
Le message :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Maintenant pour ceux qui auront la bonte de se pencher sur mon probleme, voila un morceau de code, celui incrimine :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php require_once('Connections/job_con.php'); ?>
<?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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "formular")) {
$insertSQL = sprintf("INSERT INTO candidati",
GetSQLValueString($HTTP_POST_VARS['nume'], "text"),
GetSQLValueString($HTTP_POST_VARS['prenume'], "text"),
GetSQLValueString($HTTP_POST_VARS['sex'], "text"),
GetSQLValueString($HTTP_POST_VARS['data_nasterii'], "date"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['adresa'], "text"),
GetSQLValueString($HTTP_POST_VARS['localitate'], "text"),
GetSQLValueString($HTTP_POST_VARS['judet'], "text"),
GetSQLValueString($HTTP_POST_VARS['tel_principal'], "text"),
GetSQLValueString($HTTP_POST_VARS['tel_secundar'], "text"),
GetSQLValueString($HTTP_POST_VARS['studii_candidat'], "text"),
GetSQLValueString($HTTP_POST_VARS['experienta_candidat'], "text"),
GetSQLValueString($HTTP_POST_VARS['nivel_profesional'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu_profesional'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu_profesional_altul'], "text"),
GetSQLValueString(isset($HTTP_POST_VARS['a']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($HTTP_POST_VARS['b']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($HTTP_POST_VARS['c']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($HTTP_POST_VARS['d']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($HTTP_POST_VARS['e']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($HTTP_POST_VARS['germana'], "text"),
GetSQLValueString($HTTP_POST_VARS['engleza'], "text"),
GetSQLValueString($HTTP_POST_VARS['franceza'], "text"),
GetSQLValueString($HTTP_POST_VARS['italiana'], "text"),
GetSQLValueString($HTTP_POST_VARS['spaniola'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu1'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu2'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu3'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu1_altul'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu2_altul'], "text"),
GetSQLValueString($HTTP_POST_VARS['domeniu3_altul'], "text"),
GetSQLValueString($HTTP_POST_VARS['salariu_minim'], "int"));
mysql_select_db($database_job_con, $job_con);
$Result1 = mysql_query($insertSQL, $job_con) or die(mysql_error());
$insertGoTo = "/interim/index.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Configuration: Windows XP
Opera 9.27