lostyazilim
tr.link

Mysql Bağlanmıyor !

8 Mesajlar 918 Okunma
lstbozum
tr.link

NariYuka NariYuka Animeci Kullanıcı
  • Üyelik 26.12.2018
  • Yaş/Cinsiyet 26 / E
  • Meslek Öğrenci
  • Konum Düzce
  • Ad Soyad O** Ç**
  • Mesajlar 232
  • Beğeniler 19 / 19
  • Ticaret 2, (%100)

Hocalarım bu hatayı alıyorum nedeni nedir ?






/**
* Install Controller Class
*
* PHP version 5.4
*
* @category PHP
* @package Controller
* @author cyberziko
* @license commercial http://getcyberworks.com/
* @link http://getcyberworks.com/
*/
class InstallerController extends BaseController
{

/**
* Load install page
*
* @return view
*/
public function index()
{
if (File::exists(app_path() . "/config/config.inc.php")) {
return Redirect::route('front.index');
} else {
return View::make('install.index');
}
}

/**
* Start install
*
* @return type
*/
public function startInstall()
{
$input = Input::all();
$rules = $rules = ['host' => 'required',
'name' => 'required',
'username' => 'required'
];

$validator = Validator::make($input, $rules);

if ($validator->fails()) {
return Response::json(
array(
'success' => false,
'errors' => $validator->getMessageBag()->toArray()
)
);
}

try {
$database_host = $input['host'];
$database_name = $input['name'];
$database_username = $input['username'];
$database_password = $input['password'];

// config
$sql_dump = app_path() . "/views/install/db_dump.sql";
$config_file_directory = app_path() . "/config/";
$config_file_name = "config.inc.php";
$config_file_default = app_path() . "/views/install/config.default";
$config_file_path = $config_file_directory . $config_file_name;

$config_file = file_get_contents($config_file_default);
$config_file = str_replace("_DB_HOST_", $database_host, $config_file);
$config_file = str_replace("_DB_NAME_", $database_name, $config_file);
$config_file = str_replace("_DB_USER_", $database_username, $config_file);
$config_file = str_replace("_DB_PASSWORD_", $database_password, $config_file);

$connection = mysql_connect($database_host, $database_username, $database_password, true);
if ($connection) {
if (mysql_select_db($database_name)) {
$f = fopen($config_file_path, "w+");
if (fwrite($f, $config_file) > 0) {
if (false == ($db_error = $this->apphp_db_install($database_name, $sql_dump, $connection))) {
return Response::json(
array(
'success' => false,
'errors' => ["Could not read file " . $sql_dump . "! Please check if the file exists."]
),
400
);
} else {
fclose($f);
return Response::json(array('success' => true));
}
}
fclose($f);
} else {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Database connecting error! Check your database exists."]
),
400
);
}
mysql_close();
}
} catch (Exception $e) {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Exception [" . $e->getMessage() . "] on file (" . $e->getFile() . ") - line:" . $e->getLine()]
),
400
);
}
}

/**
* Import dump file
*
* @param type $database database
* @param type $sql_file sql file
* @param type $connection connection
*
* @return boolean
*/
private function apphp_db_install($database, $sql_file, $connection)
{
$db_error = false;
if (!$this->apphp_db_select_db($database)) {
if ($this->apphp_db_query('create database ' . $database)) {
$this->apphp_db_select_db($database);
} else {
$db_error = mysql_error();
return false;
}
}

if (!$db_error) {
if (file_exists($sql_file)) {
$fd = fopen($sql_file, 'rb');
$restore_query = fread($fd, filesize($sql_file));
fclose($fd);
} else {
$db_error = 'SQL file does not exist: ' . $sql_file;
return false;
}

$sql_array = array();
$sql_length = strlen($restore_query);
$pos = strpos($restore_query, ';');
for ($i = $pos; $i < $sql_length; $i++) {
if ($restore_query[0] == '#') {
$restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n")));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue;
}
$next = '';
if ($restore_query[($i + 1)] == "\n") {
for ($j = ($i + 2); $j < $sql_length; $j++) {
if (trim($restore_query[$j]) != '') {
$next = substr($restore_query, $j, 6);
if ($next[0] == '#') {
// find out where the break position is so we can remove this line (#comment line)
for ($k = $j; $k < $sql_length; $k++) {
if ($restore_query[$k] == "\n")
break;
}
$query = substr($restore_query, 0, $i + 1);
$restore_query = substr($restore_query, $k);
// join the query before the comment appeared, with the rest of the dump
$restore_query = $query . $restore_query;
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue 2;
}
break;
}
}
if ($next == '') { // get the last insert query
$next = 'insert';
}
if ((preg_match('/create/i', $next)) || (preg_match('/insert/i', $next)) || (preg_match('/drop t/i', $next))) {
$next = '';
$sql_array[] = substr($restore_query, 0, $i);
$restore_query = ltrim(substr($restore_query, $i + 1));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
}
}
}

for ($i = 0; $i < sizeof($sql_array); $i++) {
$this->apphp_db_query($sql_array[$i], $connection);
}
return true;
} else {
return false;
}
}

/**
* Select database
*
* @param type $database database
*
* @return type
*/
private function apphp_db_select_db($database)
{
return mysql_select_db($database);
}

/**
* Execute query
*
* @param type $query query
* @param type $connection connection
*
* @return type
*/
private function apphp_db_query($query, $connection)
{
$res = mysql_query($query, $connection);
return $res;
}
}

 

 

Anime izlemenin adresi : Animeciturk.com
wmaraci
reklam

OmerGunay OmerGunay https://omergunay.net Kullanıcı
  • Üyelik 15.05.2015
  • Yaş/Cinsiyet 33 / E
  • Meslek PHP Developer
  • Konum İstanbul Avrupa
  • Ad Soyad Ö** G**
  • Mesajlar 1207
  • Beğeniler 382 / 381
  • Ticaret 16, (%100)
NariYuka pdo kullan demiş zaten pdo kullanın
 

 

Herkes yediğinden ikram eder..(Yavuz Sultan Selim)

NariYuka NariYuka Animeci Kullanıcı
  • Üyelik 26.12.2018
  • Yaş/Cinsiyet 26 / E
  • Meslek Öğrenci
  • Konum Düzce
  • Ad Soyad O** Ç**
  • Mesajlar 232
  • Beğeniler 19 / 19
  • Ticaret 2, (%100)
keşke yapabilsem (pdo bilmiyorum) :( yardım edebilecek biri varmı ?
 

 

Anime izlemenin adresi : Animeciturk.com

alperi alperi alperperi.com Kullanıcı
  • Üyelik 23.11.2016
  • Yaş/Cinsiyet 42 / E
  • Meslek Bilgiişlem
  • Konum Konya
  • Ad Soyad A** P**
  • Mesajlar 642
  • Beğeniler 216 / 215
  • Ticaret 4, (%100)
/**
* Install Controller Class
*
* PHP version 5.4
*
* @category PHP
* @package Controller
* @author cyberziko
* @license commercial http://getcyberworks.com/
* @link http://getcyberworks.com/
*/
class InstallerController extends BaseController
{

/**
* Load install page
*
* @return view
*/
public function index()
{
if (File::exists(app_path() . "/config/config.inc.php")) {
return Redirect::route('front.index');
} else {
return View::make('install.index');
}
}

/**
* Start install
*
* @return type
*/
public function startInstall()
{
$input = Input::all();
$rules = $rules = ['host' => 'required',
'name' => 'required',
'username' => 'required'
];

$validator = Validator::make($input, $rules);

if ($validator->fails()) {
return Response::json(
array(
'success' => false,
'errors' => $validator->getMessageBag()->toArray()
)
);
}

try {
$database_host = $input['host'];
$database_name = $input['name'];
$database_username = $input['username'];
$database_password = $input['password'];

// config
$sql_dump = app_path() . "/views/install/db_dump.sql";
$config_file_directory = app_path() . "/config/";
$config_file_name = "config.inc.php";
$config_file_default = app_path() . "/views/install/config.default";
$config_file_path = $config_file_directory . $config_file_name;

$config_file = file_get_contents($config_file_default);
$config_file = str_replace("_DB_HOST_", $database_host, $config_file);
$config_file = str_replace("_DB_NAME_", $database_name, $config_file);
$config_file = str_replace("_DB_USER_", $database_username, $config_file);
$config_file = str_replace("_DB_PASSWORD_", $database_password, $config_file);

$connection = mysqli_connect($database_host, $database_username, $database_password, true);
if ($connection) {
if (mysqli_select_db($database_name)) {
$f = fopen($config_file_path, "w+");
if (fwrite($f, $config_file) > 0) {
if (false == ($db_error = $this->apphp_db_install($database_name, $sql_dump, $connection))) {
return Response::json(
array(
'success' => false,
'errors' => ["Could not read file " . $sql_dump . "! Please check if the file exists."]
),
400
);
} else {
fclose($f);
return Response::json(array('success' => true));
}
}
fclose($f);
} else {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Database connecting error! Check your database exists."]
),
400
);
}
mysqli_close();
}
} catch (Exception $e) {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Exception [" . $e->getMessage() . "] on file (" . $e->getFile() . ") - line:" . $e->getLine()]
),
400
);
}
}

/**
* Import dump file
*
* @param type $database database
* @param type $sql_file sql file
* @param type $connection connection
*
* @return boolean
*/
private function apphp_db_install($database, $sql_file, $connection)
{
$db_error = false;
if (!$this->apphp_db_select_db($database)) {
if ($this->apphp_db_query('create database ' . $database)) {
$this->apphp_db_select_db($database);
} else {
$db_error = mysqli_error();
return false;
}
}

if (!$db_error) {
if (file_exists($sql_file)) {
$fd = fopen($sql_file, 'rb');
$restore_query = fread($fd, filesize($sql_file));
fclose($fd);
} else {
$db_error = 'SQL file does not exist: ' . $sql_file;
return false;
}

$sql_array = array();
$sql_length = strlen($restore_query);
$pos = strpos($restore_query, ';');
for ($i = $pos; $i < $sql_length; $i++) {
if ($restore_query[0] == '#') {
$restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n")));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue;
}
$next = '';
if ($restore_query[($i + 1)] == "\n") {
for ($j = ($i + 2); $j < $sql_length; $j++) {
if (trim($restore_query[$j]) != '') {
$next = substr($restore_query, $j, 6);
if ($next[0] == '#') {
// find out where the break position is so we can remove this line (#comment line)
for ($k = $j; $k < $sql_length; $k++) {
if ($restore_query[$k] == "\n")
break;
}
$query = substr($restore_query, 0, $i + 1);
$restore_query = substr($restore_query, $k);
// join the query before the comment appeared, with the rest of the dump
$restore_query = $query . $restore_query;
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue 2;
}
break;
}
}
if ($next == '') { // get the last insert query
$next = 'insert';
}
if ((preg_match('/create/i', $next)) || (preg_match('/insert/i', $next)) || (preg_match('/drop t/i', $next))) {
$next = '';
$sql_array[] = substr($restore_query, 0, $i);
$restore_query = ltrim(substr($restore_query, $i + 1));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
}
}
}

for ($i = 0; $i < sizeof($sql_array); $i++) {
$this->apphp_db_query($sql_array[$i], $connection);
}
return true;
} else {
return false;
}
}

/**
* Select database
*
* @param type $database database
*
* @return type
*/
private function apphp_db_select_db($database)
{
return mysqli_select_db($database);
}

/**
* Execute query
*
* @param type $query query
* @param type $connection connection
*
* @return type
*/
private function apphp_db_query($query, $connection)
{
$res = mysqli_query($query, $connection);
return $res;
}
}


bu şekilde bir denermisin
 

 

wmaraci
wmaraci

NariYuka NariYuka Animeci Kullanıcı
  • Üyelik 26.12.2018
  • Yaş/Cinsiyet 26 / E
  • Meslek Öğrenci
  • Konum Düzce
  • Ad Soyad O** Ç**
  • Mesajlar 232
  • Beğeniler 19 / 19
  • Ticaret 2, (%100)
bu hatayı aldım

 

 

Anime izlemenin adresi : Animeciturk.com

alperi alperi alperperi.com Kullanıcı
  • Üyelik 23.11.2016
  • Yaş/Cinsiyet 42 / E
  • Meslek Bilgiişlem
  • Konum Konya
  • Ad Soyad A** P**
  • Mesajlar 642
  • Beğeniler 216 / 215
  • Ticaret 4, (%100)
/**
* Install Controller Class
*
* PHP version 5.4
*
* @category PHP
* @package Controller
* @author cyberziko
* @license commercial http://getcyberworks.com/
* @link http://getcyberworks.com/
*/
class InstallerController extends BaseController
{

/**
* Load install page
*
* @return view
*/
public function index()
{
if (File::exists(app_path() . "/config/config.inc.php")) {
return Redirect::route('front.index');
} else {
return View::make('install.index');
}
}

/**
* Start install
*
* @return type
*/
public function startInstall()
{
$input = Input::all();
$rules = $rules = ['host' => 'required',
'name' => 'required',
'username' => 'required'
];

$validator = Validator::make($input, $rules);

if ($validator->fails()) {
return Response::json(
array(
'success' => false,
'errors' => $validator->getMessageBag()->toArray()
)
);
}

try {
$database_host = $input['host'];
$database_name = $input['name'];
$database_username = $input['username'];
$database_password = $input['password'];

// config
$sql_dump = app_path() . "/views/install/db_dump.sql";
$config_file_directory = app_path() . "/config/";
$config_file_name = "config.inc.php";
$config_file_default = app_path() . "/views/install/config.default";
$config_file_path = $config_file_directory . $config_file_name;

$config_file = file_get_contents($config_file_default);
$config_file = str_replace("_DB_HOST_", $database_host, $config_file);
$config_file = str_replace("_DB_NAME_", $database_name, $config_file);
$config_file = str_replace("_DB_USER_", $database_username, $config_file);
$config_file = str_replace("_DB_PASSWORD_", $database_password, $config_file);

$conn = mysqli_connect($database_host, $database_username, $database_password, $database_name) or die("Unable to Connect");
if ($conn) {
if (mysqli_select_db($database_name)) {
$f = fopen($config_file_path, "w+");
if (fwrite($f, $config_file) > 0) {
if (false == ($db_error = $this->apphp_db_install($database_name, $sql_dump, $conn))) {
return Response::json(
array(
'success' => false,
'errors' => ["Could not read file " . $sql_dump . "! Please check if the file exists."]
),
400
);
} else {
fclose($f);
return Response::json(array('success' => true));
}
}
fclose($f);
} else {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Database connecting error! Check your database exists."]
),
400
);
}
mysqli_close();
}
} catch (Exception $e) {
return Response::json(
array(
'success' => false,
'errors' => ["Error : Exception [" . $e->getMessage() . "] on file (" . $e->getFile() . ") - line:" . $e->getLine()]
),
400
);
}
}

/**
* Import dump file
*
* @param type $database database
* @param type $sql_file sql file
* @param type $conn connection
*
* @return boolean
*/
private function apphp_db_install($database, $sql_file, $conn)
{
$db_error = false;
if (!$this->apphp_db_select_db($database)) {
if ($this->apphp_db_query('create database ' . $database)) {
$this->apphp_db_select_db($database);
} else {
$db_error = mysqli_error();
return false;
}
}

if (!$db_error) {
if (file_exists($sql_file)) {
$fd = fopen($sql_file, 'rb');
$restore_query = fread($fd, filesize($sql_file));
fclose($fd);
} else {
$db_error = 'SQL file does not exist: ' . $sql_file;
return false;
}

$sql_array = array();
$sql_length = strlen($restore_query);
$pos = strpos($restore_query, ';');
for ($i = $pos; $i < $sql_length; $i++) {
if ($restore_query[0] == '#') {
$restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n")));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue;
}
$next = '';
if ($restore_query[($i + 1)] == "\n") {
for ($j = ($i + 2); $j < $sql_length; $j++) {
if (trim($restore_query[$j]) != '') {
$next = substr($restore_query, $j, 6);
if ($next[0] == '#') {
// find out where the break position is so we can remove this line (#comment line)
for ($k = $j; $k < $sql_length; $k++) {
if ($restore_query[$k] == "\n")
break;
}
$query = substr($restore_query, 0, $i + 1);
$restore_query = substr($restore_query, $k);
// join the query before the comment appeared, with the rest of the dump
$restore_query = $query . $restore_query;
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
continue 2;
}
break;
}
}
if ($next == '') { // get the last insert query
$next = 'insert';
}
if ((preg_match('/create/i', $next)) || (preg_match('/insert/i', $next)) || (preg_match('/drop t/i', $next))) {
$next = '';
$sql_array[] = substr($restore_query, 0, $i);
$restore_query = ltrim(substr($restore_query, $i + 1));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';') - 1;
}
}
}

for ($i = 0; $i < sizeof($sql_array); $i++) {
$this->apphp_db_query($sql_array[$i], $conn);
}
return true;
} else {
return false;
}
}

/**
* Select database
*
* @param type $database database
*
* @return type
*/
private function apphp_db_select_db($database)
{
return mysqli_select_db($database);
}

/**
* Execute query
*
* @param type $query query
* @param type $conn connection
*
* @return type
*/
private function apphp_db_query($query, $conn)
{
$res = mysqli_query($query, $conn);
return $res;
}
}


bu şekilde denermisin
 

 

NariYuka NariYuka Animeci Kullanıcı
  • Üyelik 26.12.2018
  • Yaş/Cinsiyet 26 / E
  • Meslek Öğrenci
  • Konum Düzce
  • Ad Soyad O** Ç**
  • Mesajlar 232
  • Beğeniler 19 / 19
  • Ticaret 2, (%100)



ilgin için teşekkür ederim hocam ama gene olmadı :(
 

 

Anime izlemenin adresi : Animeciturk.com

alperi alperi alperperi.com Kullanıcı
  • Üyelik 23.11.2016
  • Yaş/Cinsiyet 42 / E
  • Meslek Bilgiişlem
  • Konum Konya
  • Ad Soyad A** P**
  • Mesajlar 642
  • Beğeniler 216 / 215
  • Ticaret 4, (%100)
Scripti komple elden geçirmek gerek sadece bağlantı sayfasını düzeltmekle olmaz mysql kullanılan sorgu, sonuc v.b. satırların tümünün mysqli için yeniden elden geçmesi gerekli.
 

 

Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al