php连接access

admin3年前PHP407
  1. 先切换到php5.2

  2. <?php
    header("Content-type:text/html;charset=utf-8");
    $con2 = mysqli_connect("localhost", "root", "root", "hengsheng");
    if (!$con2) {
        die('Could not connect: ' . mysqli_error());
    }
    mysqli_query($con2, 'SET NAMES UTF8');
    $db = new PDO("odbc:driver={microsoft access driver (*.mdb)};dbq=".realpath("a.mdb")) or die("Connect Error");
    $rs = $db->query('select * from Product where Bigclassid = 2 order by articleID');
    
    
    foreach ($rs as $v) {
        $title = iconv('gb2312', 'utf-8', $v['Title']);
        $content = str_replace(array('http://www.yyhssp.com/image/'), array('/image/'), addslashes( iconv('gb2312', 'utf-8', $v['content']) ) );
        $litpic = '/'.$v['DefaultPicUrl'];
        $add_time = strtotime($v['UpdateTime']);
        $click = intval($v['Hits']);
    
        $sql = "insert into hengsheng_archives(typeid,title,channel,is_litpic,litpic,click,arcrank,seo_title,seo_keywords,seo_description,sort_order,lang,add_time,update_time) values(3, '$title', 34, 1, '$litpic','$click',0,'$title','$title','$title','1000','cn','$add_time','$add_time');";
    
        $r = mysqli_query($con2, $sql);
        if (!$r) {
            die('Could not connect: ' . mysqli_error());
        }
        $id = mysqli_insert_id($con2);
        $sql = "insert into hengsheng_pics_content(aid,content,add_time,update_time) values($id,'$content','$add_time','$add_time')";
        mysqli_query($con2, $sql);
    }

相关文章

php连接access数据库

<?php header("Content-type:text/html;charset=utf-8"); $db = new PDO(&q...

安装Composer报错php_igbinary.dll' - 找不到指定的模块。

首先去php\php-7.1.13-nts\ext中找,并未发现有php_igbinary.dll文件,然后去该网站下载适合自己的文件 网址:https://windows.php.net/downl...

PHP中的闭包function() use() {}使用场景和技巧

https://www.jb51.net/article/269921.htm...

php切片上传

html    <style>        html {...

2023年最新的28道PHP面试题附答案

https://www.swvq.com/boutique/detail/6734...

redis

进入CMD命令进入相应redis目录cd redisredis-server.exe redis.windows.conf...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。