Witam, mam problem z wykonaniem UPDATEu w liniach: 61 - 69. Catch nie wywala żadnego Exception.
<?php
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index');
exit();
}
require_once "connect.php";
mysqli_report(MYSQLI_REPORT_STRICT);
try
{
$polaczenie = new mysqli($host, $db_user, $db_password, $db_name);
$polaczenie->set_charset("utf8");
if ($polaczenie->connect_errno!=0)
{
throw new Exception(mysqli_connect_errno());
}
else
{
$sql = "SELECT * FROM `user` ORDER BY `name` ASC";
$rezultat = $polaczenie->query($sql);
if(!$rezultat) throw new Exception($polaczenie->error);
$ilosc_wierszy = $rezultat->num_rows;
if ($ilosc_wierszy > 0)
{
while ($i = $rezultat->fetch_assoc())
{
require_once ('simple_html_dom.php');
$id_gol = $i['id_gol'];
$html = file_get_html("ID=". $id_gol);
$img = $html->find(".bbox",0)->src;
$img = iconv('CP1250','UTF-8',$img);
$img = "ID".$img;
$name = $html->find(".S016 h1",0)->innertext;
$name = iconv('CP1250','UTF-8',$name);
$name = str_replace(' [PC]', '', $name);
$name = htmlentities($name, ENT_QUOTES, "UTF-8");
$lang = $html->find(".S016-lang p b",0)->innertext;
$lang = iconv('CP1250','UTF-8',$lang);
$date = $html->find(".S016-data p b",2)->innertext;
$date = iconv('CP1250','UTF-8',$date);
if(!empty($id_gol))
{
$sql2 = "UPDATE `user` SET `img` = '$img', `name` = '$name', `lang` = '$lang', `date` = '$date' WHERE `user`.`id` = '$id_gol';";
$rezultat2 = $polaczenie->query($sql2);
if(!$rezultat2) throw new Exception($polaczenie->error);
}
}
}
else
{
$_SESSION['error_msg']='<div class="error">Baza danych jest pusta.</div>'."\n";
$polaczenie->close();
header('Location: update');
exit();
}
$polaczenie->close();
header('Location: update');
exit();
}
}
catch(Exception $e)
{
$_SESSION['error_msg']='Informacja błedu: '.$e;
// $_SESSION['error_msg']='<div class="error">Błąd serwera! Spróbuj ponownie później lub skontaktuj się z administracją.</div>'."\n";
header('Location: update');
}
?>