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

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

报告相同问题?

悬赏问题

  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗