Jump to content
php.lv forumi

Mysqli sample!


thesnarkie

Recommended Posts

<?
$mysqli = new mysqli("localhost", "", "", "");
$mysqli->query("SET NAMES utf8");
$mysqli->query("SET CHARACTER SET utf8");

$result = $mysqli->query("SELECT COUNT(a.id) AS idCount FROM account AS a WHERE a.username='freezer'");
$row = $result->fetch_array(MYSQLI_ASSOC);

$mysqli->close();
?>

 

Vārdu sakot, pēc baigo query izsaukšanas pašās koda beigās izsaucot close() daudz kas mainīsies? Nu servera resursi.. Un,kas notiek ja viņu neizsauc koda beigās?

Edited by thesnarkie
Link to comment
Share on other sites

index.php

<?
$mysqli = new mysqli($host, $username, $password, $database);
$mysqli->query("SET NAMES utf8");
$mysqli->query("SET CHARACTER SET utf8");

$result = $mysqli->query("SELECT COUNT(a.id) AS idCount FROM account AS a WHERE a.username='freezer'");
$row = $result->fetch_array();

include("super.php");

$mysqli->close();
?>

 

super.php

<?
$host = "localhost";
$username = "blala";
$password = "blala"; 
$database = "blala";
?>

 

Tas ir ok no drošības viedokļa, ka inklūdoju failu ar mysql detailiem? Tur neko nekā nevar izvilkt?

Edited by thesnarkie
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...