简体   繁体   中英

Why isn't working on my ubuntu server that is working on my localhost PHP SQL insert?

my code is logging people's ip in the mysql data.table.So, the problem is it's working on my localhost but when I transfer my files to my ubuntu server it's not working. There is no error or something on my website. But the data is not covering in my data.table above the server. here is the iplog.php

<?php
include 'configserver.php';
    
    $url=$_SERVER['REQUEST_URI'];
    $ip=$_SERVER['REMOTE_ADDR'];
    $host=$_SERVER['SERVER_NAME'];
    $log= $db->prepare("INSERT INTO iplog (ip,url,hostname) VALUES (:ip,:url,:hostname)");
    $log->bindParam(':ip', $ip);
    $log->bindParam(':url', $url);
    $log->bindParam(':hostname', $host);
    

    $log->execute();
    


?>

在这里,在我的 localhost/phpMyAdmin 上,它的工作原理如您所见

我的 ubuntu 服务器 iplog 表是空的,如您所见,我已经返回 100 次 iplog.php,但它没有插入日志数据:mywebsite.com/phpMyAdmmin

Did you try to add the following code just after $log->execute() to fetch the last PDOStatement error?

echo "\nPDOStatement::errorInfo():\n";
$arr = $log->errorInfo();
print_r($arr);

@See PDOStatement::errorInfo

Check your PDO drivers settings with phpinfo(); and make sure there is a driver enabled for your database engine.

Also, make sure that PDO autocommit is enabled on your remote server.

I solved the problem. I created another table in my server's MySQL and changed the data way it solved. Thank you for all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM