php - How to work with MySQLi? -
i new on mysqli connection. have scheme codes here , working on wamp server localhost. changed old mysql connection new mysqli connection , got rid of these "deprecated errors". but problem not login or access query (sql related function). saying got rid of deprecated errors not login/access database.
//this old connection:
mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("towertec_master") or die(mysql_error());
//this new connection
$link = mysqli_connect ("localhost", "root", "", "towertec_master") or die(mysql_error());
also here old fetch connection:
$sql=mysql_query("select organization_name,address,phone,email system_config"); $row=mysql_fetch_assoc($sql); $organization_name=stripslashes(trim($row['organization_name'])); $address=stripslashes(trim($row['address'])); $phone=stripslashes(trim($row['phone'])); $email=stripslashes(trim($row['email']));
new fetch connection:
$query = "select organization_name, address, phone, email system_config" or die("error in consult.." . mysqli_error($link)); $result = mysqli_query($link, $query);
as pointed out, still using deprecated error function. also, connection, need create connection object "new".
$link = new mysqli_connect ("localhost", "root", "", "towertec_master"); if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); }
for query, putting error function in wrong place.
$query = "select organization_name, address, phone, email system_config"; $result = mysqli_query($link, $query); if (!$result) { printf("error: %s\n", mysqli_error($link)); }
php mysqli
No comments:
Post a Comment