douyaju4749 2017-03-10 18:47
浏览 36
已采纳

Mysqli Raspberry Pi 3没有任何错误[重复]

Today i am back with another MySQL problem on my Raspberry.

I have a code which inserts me a user input in the table 'users' on the database 'users' which looks like this:

BTW i know logging in with root is not the safest way but i tried to be sure that i dint messed up my MySQL user.

$mysqli = new mysqli("localhost", "root", "passwd", "users");

$mysqli->query("INSERT INTO `users` (username, email, firstname, lastname, password) VALUES ('$username', '$email', '$fname', '$lname', '$passwdhash')");
$mysqli->commit();

This worked fine until i nuked my Raspberry because i had a problem with my ssh server.

i installed everything new (php, mysql, phpmyadmin, apache2) and now my script isnt working.

I checked the status of my apache and mysql service and both are working fine. (acc. to my Raspberry)

For error catching i tried this:

$success = $mysqli->query('localhost', 'root', 'passwd', 'users');
if (!$success) {
print_r($mysqli->error);
}

I dint know if the problem is my Raspberry or my script so i am asking here to be sure that its not my script that is causing the error.

Thank you for your help.

</div>
  • 写回答

1条回答 默认 最新

  • dongyukui8330 2017-03-10 18:56
    关注

    what you are trying is wrong. try like below:-

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors',1);
    $mysqli = new mysqli('localhost', 'root', 'passwd', 'users');
    
    if ($mysqli->connect_errno) {
        echo "Error: Failed to make a MySQL connection, here is why: 
    ";
        echo "Error: " . $mysqli->connect_error . "
    ";
        exit;
    }
    

    Note:- check this an i hope you will get either some error or get connected

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)