Connexion a une base de données MySql

Daniel- Messages postés 3 Date d'inscription mercredi 28 mai 2014 Statut Membre Dernière intervention 2 juin 2014 - 28 mai 2014 à 20:34
NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 - 31 mai 2014 à 22:43
slt a tous
j'ais cree un formulaire ,il faut le remlir les tous les information sont enregistrer dans ma base de donnéé mysql
et aussi dans un tableux sur ma page web , il m'affiche le message d'erreur suivant :

SCREAM: Error suppression ignored for
( ! ) Warning: sprintf(): Too few arguments in C:\wamp\www\TT_adm\administration\ajouter-tt.php on line 46

l'erreur indiquer est ici :

GetSQLValueString($_POST['telephone3'], "double"));

<?php require_once('../Connections/conn_datasoft.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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "commandform")) {
$insertSQL = sprintf("INSERT INTO commande (id, nomsociete, adress, mail, tel, typelogiciel, etat) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['adress'], "text"),
GetSQLValueString($_POST['nomsociete'], "text"),
GetSQLValueString($_POST['telephone2'], "text"),
GetSQLValueString($_POST['typelogiciel'], "text"),
GetSQLValueString($_POST['telephone'], "double"),
GetSQLValueString($_POST['telephone3'], "double"));

mysql_select_db($database_conn_datasoft, $conn_datasoft);
$Result1 = mysql_query($insertSQL, $conn_datasoft) or die(mysql_error());

$insertGoTo = "consulter-departement-tt.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Discovery Data Soft</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style type="text/css">
.homepage h2 strong {
font-family: Georgia, Times New Roman, Times, serif;
}
</style>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/slider.js"></script>
<script type="text/javascript" src="../js/superfish.js"></script>

<script type="text/javascript" src="../js/custom.js"></script>
</head>

<body class="homepage">
<h2><strong>Ajouter département TT</strong></h2>
<div align="center"></div>
<p> </p>
<div id="containerblan">
<div id="containernew">
<div class="clear"></div>
</div>
</div>
<?php include("form1-ajouter-departement.php"); ?>
</body>
</html>


merciii d'avanceeeeee ..... :)

2 réponses

NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 159
28 mai 2014 à 21:08
Le message est clair :
Warning: sprintf(): Too few arguments in C:\wamp\www\TT_adm\administration\ajouter-tt.php on line 46

Tu utilises sprintf, mais le nombre de jokers "%*" ne correspond pas au nombre de paramètres passés à la fonction.
0
Daniel- Messages postés 3 Date d'inscription mercredi 28 mai 2014 Statut Membre Dernière intervention 2 juin 2014
29 mai 2014 à 02:48
merci henry , j'ai une autre probleme , il maffiche cet erreur

WARNING: MYSQL_FREE_RESULT(): 10 IS NOT A VALID MYSQL RESULT RESOURCE IN C:\WAMP\WWW\TT_ADM\ADMINISTRATION\CONSULTER-DEPARTEMENT-TT.PHP ON LINE 78


voila le code
<?php require_once('../Connections/conn_datasoft.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;
}
}

mysql_select_db($database_conn_datasoft, $conn_datasoft);
$query_Recordset11 = "SELECT departement_tt.id, departement_tt.Gouvernement, departement_tt.adress, departement_tt.Telephone, departement_tt.Type_TT, departement_tt.Longitude, departement_tt.Latitude FROM departement_tt";
$Recordset11 = mysql_query($query_Recordset11, $conn_datasoft) or die(mysql_error());
$row_Recordset11 = mysql_fetch_assoc($Recordset11);
$totalRows_Recordset11 = mysql_num_rows($Recordset11);mysql_select_db($database_conn_datasoft, $conn_datasoft);
$query_Recordset11 = "SELECT departement_tt.id, departement_tt.Gouvernement, departement_tt.adress, departement_tt.Telephone, departement_tt.Type_TT, departement_tt.Longitude, departement_tt.Latitude FROM departement_tt";
$Recordset11 = mysql_query($query_Recordset11, $conn_datasoft) or die(mysql_error());
$row_Recordset11 = mysql_fetch_assoc($Recordset11);
$totalRows_Recordset11 = mysql_num_rows($Recordset11);
?>
<style type="text/css">
body table tr td {
font-weight: bold;
}
</style>

<br />
<h1>Consultation des départements TT</h1><br /><br />
<table width="1420" height="52" border="0">
<tr>
<td width="147">ID</td>
<td width="147"><strong>Gouvernement </strong></td>
<td width="137"><strong>Adresse</strong></td>
<td width="136"><strong>Téléphone</strong></td>
<td width="169">Type</td>
<td width="169"><strong>Longtitide</strong></td>
<td width="159"><strong>Latitude</strong></td>
<td width="159">Supprimer</td>
<td width="159">Modifer</td>
</tr>
<tr>
<td><?php echo $row_Recordset11['id']; ?></td>
<td><?php echo $row_Recordset11['Gouvernement']; ?></td>
<td><?php echo $row_Recordset11['adress']; ?></td>
<td><?php echo $row_Recordset11['Telephone']; ?></td>
<td><?php echo $row_Recordset11['Type_TT']; ?></td>
<td><?php echo $row_Recordset11['Longitude']; ?></td>
<td> </td>
<td><form id="formsup" name="formsup" method="post" action="">
<label>
<input name="id" type="hidden" />
<input type="image" name="supprimer" id="supprimer" src="../images/sup.png" />
</label>
</form></td>
<td><form id="formaccepter" name="formaccepter" method="POST">
<label>
<input name="idcom" type="hidden" />
<input name="etat" type="hidden" />
<input type="image" name="accepter" id="accepter" src="../images/vv.jpg" />
</label>
</form></td>
</tr>
</table>
<p>  </p>
<?php
mysql_free_result($Recordset11);
?>

et merciiiiiiiiiiiii encore
0
NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 159
31 mai 2014 à 22:43
A moins de manipuler de grosses quantité de données dans ton script, il n'est pas obligatoire de libérer explicitement les données.
A voir, ce que ça donne si tu retire la ligne incriminée (ou la mettre en commentaire).
0
Rejoignez-nous