doushi4956 2015-10-25 21:43
浏览 31

试图了解如何使用PHP与Access

Update 1: @Fred -ii- Thanks! That resolved that issue by restarting those services.

Next problem that I'm getting when running in Neatbeans now

Uncaught exception 'PDOException' with message 'SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I understand that Access is not the preferred method, but this for a Project so the tools are out of my hands.

To clarify I am running this on Windows 7 x64.

This is what I'm making -

A php login that will see if a user exist in a database already, if not it will add them. For simplicity's sake we're not concerned if someone else already has this user name.

I have no PHP experience, so after finally getting XAMMP and all other required things setup to run PHP through Neatbeans, I'm at a new problem involving PDO and understanding how it works.

    <?php

echo '<pre>';
print_r(PDO::getAvailableDrivers());

if(isset($_REQUEST['attempt']))
{
    $user = $_POST['user'];
    $password = $_POST['password'];
}


//Path to our database
$database_path = "./Users.accdb";

if(!file_exists($database_path))
{
    die("Acess database file not found!");
}


$conn = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=".$database_path.";Uid=; Pwd=;");


?>
<form method="post" action="index.php?attempt">
    User <input type="text" name="user" /><br />
    Pass <input type="password" name="password"><br />

    <input type="submit" />
    </form>

Everything worked until I had to actually open a connection to the database. This is the error I'm getting when I run in Netbeans.

"Fatal error:  Uncaught exception 'PDOException' with message 'could not find driver' in C:\xampp\htdocs\Php_Login\index.php:22"

This is the output of my available drivers.

[0] => mysql
[1] => sqlite

Am I missing something? I've read through so many pages and I still can't understand why I don't have the required driver for this. I'm not asking anyone to do my Project for me, just some insight into my current roadblock.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • drny60365 2015-10-25 21:47
    关注

    are you on a windows machine?

    make sure the system has odbc set up.

    You can see this link as guide.

    You should also checkout this stackoverflow post

    And this


    Edit:

    You also need to make sure that you restarted all services after making changes to system files. Those changes will not take effect until you do.

    Edit:

    Also ensure you absolute path to the file is used

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮