Guys, please help me figure it out. I understand programming very badly, and therefore I appeal to you. I can't connect to MySQL. When I type in the browser http: //sayt.ru/install.php, a page with windows for entering the connection data to the MYSQL opens. But when I enter, dbhost: localhost, dbusername: username, dbpass: password, dbname: database name and press the next button, the page simply refreshes and prompts you to enter the data again. Who knows, please tell me what's wrong? Perhaps in the "install.php" you need to prescribe something, or change? I would really appreciate any hint. Here is the script:

<? error_reporting(0); if ($state == "") { echo "<center><b>Установка и настройка скриптов казино, ШАГ 1</b><br><br>"; echo "Перед началом установки, создайте на своем сервере пустую базу данных,<br> и впишите параметры для подключенния ниже</center> <table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"10\"> <FORM action=install.php method=post> <TR><td>DB host</td><TD><INPUT size=20 name=host value=localhost></TD></TR> <TR><td>DB username</td><TD><INPUT size=20 name=user></TD></TR> <TR><td>DB password</td><TD><INPUT size=20 name=pass></TD></TR> <TR><td>DB name</td><TD><INPUT size=20 name=name></TD></TR> <TR><TD><INPUT type=hidden value=1 name=state> <INPUT type=submit value=\"Далее...\"></TD></TR> </FORM> </table> <h2>ВНИМАНИЕ !!!</h2> <b>Перед установкой, найдите файл setup.php и дайте ему права на запись (777)</b> "; exit; } if ($state == "1") { $fr=fopen("setup.php","w+"); fwrite($fr, '<'."?\n"); fwrite($fr, 'error_reporting(0);'."\n"); fwrite($fr, '$dbhost="'.$host.'";'."\n"); fwrite($fr, '$dbuname="'.$user.'";'."\n"); fwrite($fr, '$dbpass="'.$pass.'";'."\n"); fwrite($fr, '$dbname="'.$name.'";'."\n"); fwrite($fr, 'mysql_connect($dbhost, $dbuname, $dbpass) or die("<br><br><center><br><br><b>Извините, но в данный момент существует проблема с подключением к MySQL серверу.<br><br>Приносим свои извинения, просим Вас зайти немного позже.</center></b>");'."\n"); fwrite($fr, 'mysql_select_db($dbname);'."\n"); fwrite($fr, '?'.'>'); fclose($fr); echo"Создание файла настроек.....ОК <br>"; 

Next come the tables.

  • Is "localhoss" a typo? - Max Zhukov
  • Write me on Skype (gt_fios) to explain such elementary really long and hard .. better to do it .. - Aios
  • And the database itself on the MySQL server is created ??? - gart67
  • @mazhor, show the install.php code. - Emil Sabitov
  • The database is created and works fine. Another engine is connected and the one that I need is not. - mazhor

2 answers 2

As gart67 already said, the $state variable is taken from the ceiling. Make a check for the existence of a state in the $_POST array. If it exists, then execute the code of your last condition (referring to configuration variables also via POST), otherwise output the form to fill out. PS error_reporting better to include, because this issue is not about production?

    Where does the $state variable come from?

    Try after error_reporting(0); add $state=$_POST["state"] .