Optymalizacja skryptu

Witam! Mam problem z tym skryptem. Działa on na moim kompuetrze - WebServ, Windows a na hostingu 000webhost.com już nie, tak jak na freewebhostingarea.com.

Wszystkie dane do bazy są podane dobrze, baza jest stworzona.

<?php

/ **********************************************

* Copyright (c) 2006 Roberto Toldo

* Permission is hereby granted, free of charge, to any person obtaining a copy of this software 

* and associated documentation files (the "Software"), to deal in the Software without restriction, 

* including without limitation the rights to use, copy, modify, merge, publish, distribute, 

* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 

* subject to the following conditions:

* The above copyright notice and this permission notice shall be included in all copies 

* or substantial portions of the Software.

* 

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 

* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 

* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 

* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 

* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*********************************************** /


include ("config.php");



if($install==true && $admin_pass!="")

{

$db = mysql_connect($db_host, $db_user, $db_password);


if ($db == FALSE)

	die ("Error, could not connect to database, check file config.php");


mysql_select_db($db_name, $db)

	or die ("Error selecting db. Check file config.php");


$query = "CREATE TABLE rtnews (id INT (5) UNSIGNED not null AUTO_INCREMENT, _rodzaj VARCHAR (30) not null, _platforma VARCHAR (30), _date VARCHAR(30), _serwer VARCHAR(30), _skill VARCHAR(30), _gg VARCHAR(30), _www VARCHAR(30), _vsvs VARCHAR(30), _info text, PRIMARY KEY (id))";



mysql_query($query, $db) 

	or die ("Error, could not create table!");


$query = "CREATE TABLE rtnews_auth (_password VARCHAR (100) not null)";


mysql_query($query, $db)

	or die ("Error, could not create table!");


$enc = md5($admin_pass);

$query = "INSERT INTO rtnews_auth (_password) VALUES ('$enc')";


mysql_query($query, $db)

	or die ("Error, could not create entry!");


echo "Installation completed 
";

echo "please delete this file... 
";

echo "use admin.php if you want to change the admin password... 
";


mysql_close($db);


}

?>	






  Admin Password

musisz gdzieś przypisać zmiennym (install,admin_pass) ich wartość z formularza, przykład poniżej

while(list($klucz,$wartosc) = each($_POST)){

	eval("\$".$klucz."='".$wartosc."';\n");

}

albo po prostu:

$install = $_POST['install'];

$admin_pass = $_POST['admin_pass'];

chociaż dziwi mnie że to na localhoscie działało

Działa! Mógłbyś dopisać jeszcze takie coś do tego poniżej?

<?php


include("config.php");


$db = mysql_connect($db_host, $db_user, $db_password);


function news_form(){

print '
';


global $news_error;


if ($news_error)

	echo "All fields are required!";


}


function new_news(){


global $db_host, $db_user, $db_password, $db_name, $rodzaj, $platforma, $serwer, $skill, $gg, $www, $vsvs, $info, $date;


$rodzaj = addslashes(stripslashes($rodzaj));

$platforma = addslashes(stripslashes($platforma));

$serwer = addslashes(stripslashes($serwer));

$skill = addslashes(stripslashes($skill));

$gg = addslashes(stripslashes($gg));

$www = addslashes(stripslashes($www));

$vsvs = addslashes(stripslashes($vsvs));

$info = addslashes(stripslashes($info));

$date = date("d-m-Y, H:i");



$db = mysql_connect($db_host, $db_user, $db_password);

if ($db == FALSE)

	die ("Errore Connecting database.");


mysql_select_db($db_name, $db)

		or die ("Error selecting database");


$query = "INSERT INTO rtnews (_rodzaj, _platforma, _date, _serwer, _skill, _gg, _www, _vsvs, _info) VALUES ('$rodzaj', '$platforma', '$date','$serwer','$skill','$gg', '$www', '$vsvs', '$info')";


if (!mysql_query($query, $db))

	die ("Error inserting entry in db");



}


  {

  if($write_news)

	if	($rodzaj!= "" && $platforma != "" && $serwer != "" && $gg != "")

		new_news();

	else

		$news_error = true;

  news_form();	  


  print("

Powrot do strony glownej...
");

  }


?>[/code]

to ten sam kod co poprzednio:

while(list($klucz, $wart) = each($_POST))	{

	eval("\$".$klucz."='".$wart."';\n");

}

albo ( żeby od razu dodać i usunąć slash’e - choć nie wiem w jakim celu to robisz ):

while(list($klucz, $wart) = each($_POST))	{

	eval("\$".$klucz."='".addslashes(stripslashes($wart))."';\n");

}

Już wszystko działa. Dzięki wielkie. To było potrzebne do dodawania rekordów w bazie danych. Tak przynajmniej był zrobiony skrypt, tylko wycialem formularz, zeby tyle na forum nie zajmowal.