insertion

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : insertion

Re: insertion

par sirakawa » 24 oct. 2014, 08:49

$insertSQL = sprintf("INSERT INTO finances (montant, date, type_de_marche) VALUES (%s, %s, %s)",

GetSQLValueString($_POST['montant'], "text"),
GetSQLValueString($_POST['date'], "text"),
GetSQLValueString($_POST['type_de_marche'], "text"));
print "$insertSQL";die(); //et passage par phpmyadmin
mysql_select_db($database_connexion, $connexion);

Re: insertion

par moogli » 23 oct. 2014, 23:54

sans message d'erreur on ne peu pas t'aider.

@+

Re: insertion

par moogli » 23 oct. 2014, 23:51

Modération :
Afin d'améliorer la lisibilité de ton message,
pense à utiliser les balises [code] ou [php] (selon le langage utilisé).

Elles sont disponibles au-dessus de la zone de saisie de ton message
lorsque tu postes un nouveau message.

Des indications sont disponibles sur la manière de mettre en forme vos messages dans la FAQ

insertion

par Ozil » 23 oct. 2014, 21:25

bonjours j'arrive pas a inserer dans la table "type_de_marche" de ma base de donnees.
cette erreur s'affiche tout l tmp et j n voi pa ou se situe l'erreur


voici mon code
<?php require_once('Connections/connexion.php');?>
<?php $type_de_marche="";?>

<?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"])) ){
mysql_select_db($database_connexion, $connexion);
$query_Recordset5 = "SELECT type_de_marche, count(id_finances) as nombretype ,sum(montant) as Montant  FROM finances group by type_de_marche" ;
$Recordset5 = mysql_query($query_Recordset5, $connexion) or die(mysql_error());
$row_recordset5 = mysql_fetch_assoc($Recordset5);
$total=mysql_num_rows($Recordset5);
  $insertSQL = sprintf("INSERT INTO finances (montant, date, type_de_marche) VALUES (%s, %s, %s)",
                   
					   GetSQLValueString($_POST['montant'], "text"),
					   GetSQLValueString($_POST['date'], "text"),
					   GetSQLValueString($_POST['type_de_marche'], "text"));

  mysql_select_db($database_connexion, $connexion);
  $Result1 = mysql_query($insertSQL, $connexion) or die(mysql_error());
}


mysql_select_db($database_connexion, $connexion);
$query_Recordset3 = "SELECT * FROM type_de_marche ";
$Recordset3 = mysql_query($query_Recordset3, $connexion) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

?>

<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "administrateur";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "limite.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<!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>ACCUEIL </title>
<link href="/templates/ol_karinpi/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<style type="text/css">
<!--
.Style1 {
	font-size: 12px;
	font-style: italic;
	color: #666666;
}
a {
	text-decoration: none;
	color: #333333;
	display: block;
}
-->
</style>
</head>

<body>
<center><table width="1000" border="0" cellpadding="0" cellspacing="0" bgcolor="#999999">
  <!--DWLayoutTable-->
  <tr>
    <td width="12" height="7"></td>
    <td width="978"></td>
    <td width="10"></td>
  </tr>
  <tr>
    <td height="497"></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
      <!--DWLayoutTable-->
      <tr>
        <td width="9" height="6"></td>
            <td width="197"></td>
            <td width="115"></td>
            <td width="393"></td>
            <td width="30"></td>
            <td width="225"></td>
            <td width="9"></td>
          </tr>
      <tr>
        <td height="18"></td>
            <td colspan="5" valign="top"><?php include "entete.php";?></td>
            <td></td>
          </tr>
      <tr>
        <td height="13"></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
      <tr>
        <td height="19"></td>
        <td></td>
        <td></td>
        <td></td>
        <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <tr>
            <td width="255" height="19" align="right" valign="top"><a href="<?php echo $logoutAction ?>">D&eacute;connexion</a></td>
              </tr>
        </table></td>
        <td></td>
      </tr>
      <tr>
        <td height="20"></td>
        <td></td>
        <td></td>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td></td>
      </tr>
      
      
      <tr>
        <td height="34"></td>
            <td colspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#999999">
                <!--DWLayoutTable-->
                <tr>
                  <td width="1" height="3"></td>
                  <td width="141"></td>
                  <td width="10"></td>
                  <td width="159"></td>
                  <td width="9"></td>
                </tr>
                <tr>
                  <td height="28"></td>
                  <td align="center" valign="middle" bgcolor="#FFFFFF"><a href="accueil.php"><strong>ACCUEIL</strong></a></td>
                      <td width="8">&nbsp;</td>
				   <td width="148" align="center" valign="middle" bgcolor="#FFFFFF"><a href="type_de_marche.php"><strong>TYPE DE MARCHE</strong></a></td>
                    </tr>
                <tr>
                  <td height="3"></td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
                </tr>
           
            </table>          </td>
            <td></td>
          </tr>
      <tr>
        <td height="35"></td>

          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="32"></td>

        <td>&nbsp;</td>
        <td colspan="3" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <tr>
            <td width="538" height="202" valign="top">&nbsp;
			
			
			 <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
        <table align="center">
		 <tr valign="baseline">
            <td nowrap align="right">Categorie:</td>
            <td><label>
			<select name="categorie" id="categorie">
                    <option>Choisir </option>
					<option selected="selected" value="<?php echo $type_de_marche; ?>"><?php echo $type_de_marche; ?></option>
                    <option>Fourniture</option>
                    <option>Service</option>
                    <option>Travaux</option>
                  </select>
                </label>			</td>
            <td>&nbsp;</td>
		 </tr>
          <tr valign="baseline">
            <td nowrap align="right">Date 
            <input name="date" type="text" id="date" /></td>
            <td>Montant 
            <input name="montant" type="text" id="montant" /></td>
            <td>&nbsp;</td>
          </tr>
         
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
            <td><input type="submit" value="Inserer"></td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <input type="hidden" name="MM_insert" value="form1">
      </form>     
			</td>
          </tr>
        </table>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="170"></td>
       
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="135"></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
     
          <tr>
            <td height="19" colspan="7" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                <!--DWLayoutTable-->
                <tr>
                  <td width="978" height="19" align="center" valign="middle"><span class="Style1">&copy; 2014 CHNU FANN /CONCEPTION BY PROMO 6 SID:UADB</span></td>
                </tr>
            </table>        </td>
          </tr>
    </table></td>
    <td></td>
  </tr>
  <tr>
    <td height="20"></td>
    <td>&nbsp;</td>
    <td></td>
  </tr>
  
</table>
</center>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

mysql_free_result($Recordset3);

//mysql_free_result($Recordset5);
?>