Bonsoir,
j'ai un formulaire avec quatre champs text afin d'indiquer une adresse IP.
J'essaye ensuite de faire une concaténation de mes 4 varibales pour les enregistrer dans ma base mais la j'ai une erreur de syntaxe que je n'arrive bien sur pas à résoudre.
Voici mon formulaire
Code :
<form id=
"form" name=
"form" method=
"POST" action=
"<?php echo $editFormAction; ?>" onsubmit=
"return TestIP();">
<div align=
"center">
<input type=
"text"class=
"boiteFormulaire" name=
"TB1" tabindex=
"1" size=
"3" maxlength=
"3" length=
"3" onkeypress=
"if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false; if(event.which < 48 || event.which > 57) return false;" style=
"text-align:center" onFocus=
"this.value=''"/>
<span
class=
"texteGrand"><strong>.</strong></span>
<input type=
"text"class=
"boiteFormulaire" name=
"TB2" tabindex=
"2" size=
"3" maxlength=
"3" length=
"3" onkeypress=
"if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false; if(event.which < 48 || event.which > 57) return false;" style=
"text-align:center" onFocus=
"this.value=''"/>
<span
class=
"texteGrand"><strong>.</strong></span>
<input type=
"text"class=
"boiteFormulaire" name=
"TB3" tabindex=
"3" size=
"3" maxlength=
"3" length=
"3" onkeypress=
"if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false; if(event.which < 48 || event.which > 57) return false;" style=
"text-align:center" onFocus=
"this.value=''"/>
<span
class=
"texteGrand"><strong>.</strong></span>
<input type=
"text"class=
"boiteFormulaire" name=
"TB4" tabindex=
"4" size=
"3" maxlength=
"3" length=
"3" onkeypress=
"if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false; if(event.which < 48 || event.which > 57) return false;" style=
"text-align:center" onFocus=
"this.value=''"/>
Et voici ensuite mon code PHP
Code :
<?php$ipserveur =
$_POST['TB1'].
".".
$_POST['TB2'].
".".
$_POST['TB3'].
".".
$_POST['TB4'];
if(!function_exists
("GetSQLValueString")){function GetSQLValueString
($theValue,
$theType,
$theDefinedValue =
"",
$theNotDefinedValue =
""){ $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")){ $insertSQL = sprintf
("INSERT INTO serveurdz (SERVEUR) VALUES (%s)",
$ipserveur);
mysql_select_db
($database_CnxCourrier,
$CnxCourrier);
$Result1 = mysql_query
($insertSQL,
$CnxCourrier) or die
(mysql_error
());
}?>L'erreur est la suivante :
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 '.122.211)' at line 1Voilà si quelqu'un avait une idée.