mysqli_connect problem
This is my login script;
<?php
$username = $_POST['username']; //kullanici adi
$password = $_POST['password']; //parola
$msg ='';
if(isset($username, $password)) {
ob_start();
include('ayar.php');
// güvenlik amaçli sql injection önlemek için sinirlama koy
$dbC = mysqli_connect($vthost, $vtkullanici, $vtsifre, $vtadi)
or die('Veri开发者_StackOverflowtabanina baglanilamadi');
$myusername = stripslashes($username);
$mypassword = stripslashes($password);
$myusername = mysqli_real_escape_string($dbC, $myusername);
$mypassword = mysqli_real_escape_string($dbC, $mypassword);
$sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=SHA('$mypassword')";//SHA çöz
$result=mysqli_query($dbC, $sql);
// kayit kontrol et
$count=mysqli_num_rows($result);
// kayit eslemesi kontrol et
if($count==1){
// esmeleme varsa oturum aç ve yönlendir
session_register("admin");
session_register("password");
$_SESSION['name']= $myusername;
header("location:raporla.php");
}
else {
$msg = "Yanlis kullanici adi yada parola";
header("location:index.php?msg=$msg");
}
ob_end_flush();
}
else {
header("location:index.php?msg=Kullanici adi yada parola girmediniz");
}
?>
in ayar.php
I have host, username etc. There is no problem up there. But the problem is that it's working great on local and any other host but not on this one. Here is the what server error log says.
[11-Jun-2011 02:01:26] PHP Fatal error: Call to undefined function mysqli_connect() in /home/bankalar/public_html/rapor/giris.php on line 9
mysqli_connect()
. I've searched for this module on my php conf. But there's no such one. Any idea?
In your php.ini (this under Windows) you should have the lines:
...
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
...
be sure to have the mysqli commented out (remove the ;
before)
Edit: as pointed out by @datasage if you're running a Linux distro lines will have a different naming, like:
; extension=msql.so
;
; ... or with a path:
;
; extension=/path/to/extension/msql.so
If you are on a shared hosting and can't access the php.ini, I suggest you drop them a line and ask to have it enabled.
If you have a private server, and don't have mysqli extension installed, follow the php manual instruction here for a guide on how to install it.
Otherwise, you might want to use the PDO class (which is in the dafault installation since php 5.1), which has big advantages even over mysqli and it's really useful to make safer your database.
Mysqli extension is not installed or its not enabled.
How to go about fixing that depends on your environment.
If you're using the MySQLi-class, you should use it Objective Oriented:
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
Check out the manual page. The call you're using is just an alias for the __construct()
-method. See if the the OO-way works for you.
Also, don't trust the user's input. Use a PreparedStatement for your Query.
精彩评论