Problème avec mon code php

Signaler
Messages postés
16
Date d'inscription
jeudi 28 mai 2009
Statut
Membre
Dernière intervention
29 juin 2010
-
Messages postés
381
Date d'inscription
lundi 12 novembre 2007
Statut
Membre
Dernière intervention
23 octobre 2014
-
Bonjour,
Je suis en train de créer un installateur automatique pour cakephp
Mais j'ai une erreur.
Pouvez-vous m'aidez

Voici le code d'installation
<?php
if(isset($_POST['settings'])) {
if(empty($_POST['sitename']) ||  empty($_POST['siteurl']) || empty($_POST['slogan']) || empty($_POST['pagination']) || empty($_POST['password'])) {
echo 'Sorry, one or more fields was left empty.';
} else {
if(!ctype_digit($_POST['pagination'])) {
echo 'Sorry, pagination MUST be a number';
} else {
if(!is_writable('../app/tmp')) {
echo 'Désolé, le répertoire app/tmp doit avoir la permission 777.';
} else {

include('../app/config/database.php');

// Create settings table
$query = mysql_query("CREATE TABLE `settings` (`id` int(11) NOT NULL auto_increment, `sitename` varchar(255) NOT NULL default '', `siteurl` varchar(255) NOT NULL default '', `slogan` text NOT NULL, `pagination` int(11) NOT NULL default '0', `password` varchar(255) NOT NULL default '', PRIMARY KEY  (`id`))") or die(mysql_error());
echo 'Settings table created!
';
// Dump setting data posted from form
mysql_query("INSERT INTO `settings` VALUES(1, '{$_POST['sitename']}', '{$_POST['siteurl']}', '{$_POST['slogan']}', '{$_POST['pagination']}', '" . md5($_POST['password']) . "')") or die(mysql_error());
echo 'Settings inserted into table.

';

// Create comments table
mysql_query("CREATE TABLE `comments` (`id` int(11) NOT NULL auto_increment, `gameid` int(11) NOT NULL default '0', `ipaddress` varchar(255) NOT NULL default '', `comment` text NOT NULL, `name` varchar(255) NOT NULL default '', PRIMARY KEY  (`id`))") or die(mysql_error());
echo 'Comments table created!

';

//Create ad table
mysql_query("CREATE TABLE `ads` (
  `header_ad` text NOT NULL,
  `sidebar_ad` text NOT NULL,
  `game_ad` text NOT NULL
)") or die(mysql_error());

// dump ad data
mysql_query("INSERT INTO `ads` VALUES('header_ad code', 'sidebar_ad code', 'game_ad code')");

// Create links table
mysql_query("CREATE TABLE `links` (`id` int(11) NOT NULL auto_increment, `sitetitle` varchar(255) NOT NULL default '', `siteurl` varchar(255) NOT NULL default '', `approved` char(3) NOT NULL default '', `email` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '', PRIMARY KEY  (`id`))") or die(mysql_error());
echo 'Links table created!

';


// Create rating table
mysql_query("CREATE TABLE `ratings` (`id` int(11) NOT NULL auto_increment, `gameid` int(11) NOT NULL default '0', `ipaddress` varchar(255) NOT NULL default '', `rating` int(11) NOT NULL default '0', PRIMARY KEY  (`id`))") or die(mysql_error());
echo 'Rating table created!

';


//Create ad table
mysql_query("CREATE TABLE `ads` (
  `header_ad` text NOT NULL,
  `sidebar_ad` text NOT NULL,
  `game_ad` text NOT NULL
)") or die(mysql_error());

// dump ad data
mysql_query("INSERT INTO `ads` VALUES('header_ad code', 'sidebar_ad code', 'game_ad code')");

echo 'Ads table created!

';


}
}
}
} elseif(isset($_GET['settings'])) {
echo '<form name="settings" method="post" action="install_script.php">
Nom du site:



Site URL:



Site Slogan:



Non d\'utilisateur


Mot de passe admin:



Adresse E-mail



</form>';
} elseif(isset($_POST['database'])) {
if(empty($_POST['host']) || empty($_POST['dbuser']) || empty($_POST['dbname']) || empty($_POST['dbpassword'])) {
echo 'Sorry, one or more fields was left empty.';
} else {
$config = "../config.php";
if(!is_writable($config)) {
die("Error: Config file not CHMODDED");
} else {
$connect = @mysql_connect($_POST['host'], $_POST['dbuser'], $_POST['dbpassword']);
$database = @mysql_select_db($_POST['dbname']);

if($connect false || $database false) {
echo 'Could not connect to the database';
} else {
$fh = fopen($config, 'w') or die("can't open file");
$stringData = '<?php
class DATABASE_CONFIG {

var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => ' . $_POST['host'] . '',
'login' => '' . $_POST['login'] . '',
'password' => '' . $_POST['password'] . '',
'database' => '' . $_POST['database_name']',
'prefix' => '',

);
var $test = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'test_database_name',
'prefix' => '',
);
}
?>';
fwrite($fh, $stringData);
fclose($fh);
echo 'Config created successfully.
[?settings=true Click here to proceed!]
';
}
}
}
} else {
echo '
Welcome to the setup!

Please ensure that you have chmodded the config.php file and the files and thumbnails folder to 777, otherwise the script will not install.


<form name="database" method="post" action="install_script.php">
Host:



Nom de la base de donnée:



Nom d\'utilisateur de la base de donnée:



Mot de passe de la base de donnée:




</form>';
} ?>



Pouvez-vous m'aider à résoudre l'erreur ou les erreurs
Merci

1 réponse

Messages postés
381
Date d'inscription
lundi 12 novembre 2007
Statut
Membre
Dernière intervention
23 octobre 2014

Bonjour,

Oui mais quelles erreurs sont renvoyées ?

++