Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

php - 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('Veritabanina 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...