Pb chechbox

Bonjour,
je voulais ajouter dans ma base plusierurs checkbox alor mon script m'affiche
Fatal error: Call to undefined function: getsqlvaluestring()

voila mon script
<?php
include("connexion.php");

$test= implode(', ' ,$_POST['nom_type']);
$query = sprintf("INSERT INTO type_accident (id_type, nom_type) VALUES (' ', '$test)",GetSQLValueString($_POST['nom_type'], "text"));
echo $query;
Configuration: Windows XP Internet Explorer 6.0

3 réponses

  • Votes
  • Date
  • Date décroissante
  1. c'est quoi le code de ta fonction pour :
    GetSQLValueString($_POST['nom_type'], "text"));
    1. bonjour,
      je resolus le probleme a propros getvaluestring en utilisant la fonction getvaluestring mais ca apparait des erreurs "Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in "
      mon script modifie
      <?php
      include("connexion.php");

      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;
      }
      }
      $test= implode(', ' ,$_POST['nom_type']);
      $query = sprintf("INSERT INTO type_accident (id_type, nom_type) VALUES ('', '$test,'')",
      GetSQLValueString($_POST['nom_type'], "text"));
      $Result1 = mysql_query($query) or die(mysql_error()); ?>

      page formulaire
      <form name="form" method="post" action="inserer.php" id="form" enctype="multipart/form-data">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">

      <tr>
      <td colspan="4"><table width="100%" border="0" cellspacing="1" cellpadding="0">
      <tr>
      <td width="18%" height="33" class="Style3">

      <input type="checkbox" name="nom_type[]" value="Incident" />
      Incident</td>
      <td width="29%" class="Style3">

      <input type="checkbox" name="nom_type[]" value="Accident" />
      Accident</td>
      <td width="33%" class="Style3">

      <input type="checkbox" name="nom_type[]" value="Quasi-accident"/>
      Quasi-accident</td>
      <td width="20%" class="Style3">

      <input type="checkbox" name="nom_type[]" value="Lésion d'une personne "/>
      Lésion d'une personne </td>
      </tr>
      <tr>
      <td height="23" class="Style3">

      <input type="checkbox" name="nom_type[]" value="Perte/ Dégat" />
      Perte/
      Dégât</td>
      <td class="Style3">

      <input type="checkbox" name="nom_type[]" value="Collison navire "/>
      Collison navire </td>
      <td class="Style3">

      <input type="checkbox" name="nom_type[]" value="déversement d'huile "/>
      déversement d'huile </td>
      <td class="Style3">

      <input type="checkbox" name="nom_type[]" value="Véhicule"/>
      Véhicule</td>
      </tr>
      </table>
      </form>