Georges Lours wrote:
Le samedi 17 février 2007, deny a écrit :
Php , non ?
Non, php, j'ai pas compris comment on pouvait faire.
Pour exécuter un code php, il faut le mettre dans une page web et l'ouvrir
avec un serveur apache. J'ai bien compris pour afficher les données, mais pas
pour les rentrer. Il faut mettre un code dans une page et l'ouvrir dans un
navigateur ?
avec une base de données mysql , tu peux inserer des données , un
fichier complet , modifier des données .
voici un exemple de nexen , d'insertion de fichier dans une base de données
| function insert_file($filename , $db , $link , $tablename , $line_end
, $field_end , $escape , $field_enclosed) {
|/* Paramètres :
* $filename : chemin d'accès au fichier à utiliser
* $db : nom de la base de données.
* $link : identifiant de lien avec le serveur MySQL
* obtenu par mysql_connect().
* $tablename : nom de la table où seront effectueés les insertions.
* $line_end : caractère séparant les lignes
* (par défaut : \n , utiliser pour prendre cette valeur).
* $field_end : caractère séparant les champs
* (par défaut : \t , utiliser pour prendre cette valeur)
* $escape : caractère d'échappement protégeant les caractères spécaiaux
* (par défaut : \\ , utiliser pour prendre cette valeur).
* $field_enclosed : bool (TRUE : les valeurs des champs sont
* entourées d'un caractère particulier).
*
* Paramètre supplémmentaire :
* $cols : tableau des noms colonnes à inserées.
* Si $field_enclosed = TRUE alors ajouter
* $enclose_char : caratère entourant les valeurs des champs (par ex. '
ou )
*/
session_name
http://www.nexen.net/php/rapide.php?quoi=session_name(SQL_insert);
session_start http://www.nexen.net/php/rapide.php?quoi=session_start();
global $id;
if (!session_is_registered
http://www.nexen.net/php/rapide.php?quoi=session_is_registered(id))
{
session_register
http://www.nexen.net/php/rapide.php?quoi=session_register(id);
$id = 0;
}
echo Si vous obtenez des messages d'erreur de MySQL, c'est que
l'insertion est incomplète, br;
echo a href=\.getenv
http://www.nexen.net/php/rapide.php?quoi=getenv(SCRIPT_NAME).\Cliquez
ici/a pour qu'elle reprenne où elle s'est arreteep;
if ($field_enclosed == FALSE)
{
if (func_num_args
http://www.nexen.net/php/rapide.php?quoi=func_num_args() = 9)
$cols = func_get_arg
http://www.nexen.net/php/rapide.php?quoi=func_get_arg(8);
}
else
{
if (func_num_args
http://www.nexen.net/php/rapide.php?quoi=func_num_args() = 9)
{
$enclose_char = func_get_arg
http://www.nexen.net/php/rapide.php?quoi=func_get_arg(8);
if (!is_string
http://www.nexen.net/php/rapide.php?quoi=is_string($enclose_char))
return FALSE;
}
else
return FALSE;
if (func_num_args
http://www.nexen.net/php/rapide.php?quoi=func_num_args() = 10)
{
$enclose_char = func_get_arg
http://www.nexen.net/php/rapide.php?quoi=func_get_arg(8);
if (!is_string
http://www.nexen.net/php/rapide.php?quoi=is_string($enclose_char))
{
$cols = $enclose_char;
$enclose_char = func_get_arg
http://www.nexen.net/php/rapide.php?quoi=func_get_arg(9);
if (!is_string
http://www.nexen.net/php/rapide.php?quoi=is_string($enclose_char))
return FALSE;
}
else
$cols = func_get_arg
http://www.nexen.net/php/rapide.php?quoi=func_get_arg(9);
}
}
if ($escape == )
$escape = addslashes
http://www.nexen.net/php/rapide.php?quoi=addslashes(\\);
else
$escape = addslashes
http://www.nexen.net/php/rapide.php?quoi=addslashes($escape);
if (isset($enclose_char))
$enclose_char = addslashes
http://www.nexen.net/php/rapide.php?quoi=addslashes($enclose_char);
if ($line_end != \n $line_end != )
{
$file_lines = file
http://www.nexen.net/php/rapide.php?quoi=file($filename);
$file = implode
http://www.nexen.net/php/rapide.php?quoi=implode(\n,$file_lines);
$line_end = addslashes
http://www.nexen.net/php/rapide.php?quoi=addslashes($line_end);
if ($field_enclosed == FALSE)
{
$reg = (([^$line_end$escape]|$escape$line_end)+)($line_end|\$);
preg_match_all
http://www.nexen.net/php/rapide.php?quoi=preg_match_all(/$reg/i,$file,$reg_lines);
}
else
{
$reg =
(([^.$line_end.$enclose_char.$escape.]|.$enclose_char.[^.$enclose_char.$escape.]*.$enclose_char.|.$escape.$line_end.)+)(.$line_end.|\$);
preg_match_all
http://www.nexen.net/php/rapide.php?quoi=preg_match_all(/$reg/i,$file,$reg_lines);
}
$lines = $reg_lines[1];
}
else
$lines = file http://www.nexen.net/php/rapide.php?quoi=file($filename);
mysql_select_db
http://www.nexen.net/php/rapide.php?quoi=mysql_select_db($db,$link);
$size = sizeof http://www.nexen.net/php/rapide.php?quoi=sizeof($lines);
session_register
http://www.nexen.net/php/rapide.php?quoi=session_register(id);
for ($i=$id;$i$size;$i++)
{
session_register
http://www.nexen.net/php/rapide.php?quoi=session_register(id);
$line = $lines[$i];
if (!preg_match
http://www.nexen.net/php/rapide.php?quoi=preg_match(/^\s*#/,$line))
{
if ($field_end == \t || $field_end == )
$line_tab = explode
http://www.nexen.net/php/rapide.php?quoi=explode(\t,$line);
else
{