在通过localhost运行时在php中出现错误
警告:mysqli_select_db()期望参数1为mysqli,string 在第9行的C:\ xampp \ htdocs \ IVPORTAL \ admin \ include \ database.php中给出
警告:mysqli_error()正好需要1个参数,给出0 第9行的C:\ xampp \ htdocs \ IVPORTAL \ admin \ include \ database.php
我没有收到错误。
<?php
require_once("config.php");
class database {
private $link;
function __construct() {
$this->link = mysqli_connect(config::host,config::username,config::password);
mysqli_select_db(config::database,$this->link) or die(mysqli_error());
}
function __distruct() {
mysqli_close($this->link);
}
答案 0 :(得分:1)
答案 1 :(得分:1)
从错误中看起来你找不到函数mysqli_error
的params以下是使用mysqli_error的语法
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:text="@string/button_send"
app:layout_constraintBaseline_toBaselineOf="@+id/editText"
app:layout_constraintLeft_toRightOf="@+id/editText"
app:layout_constraintRight_toRightOf="parent" />
作为参考我已更新您的代码
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("My app","Button is pressed");
Toast.makeText(MainActivity.this,"Button pressed",Toast.LENGTH_SHORT).show();
sendMessage();
}
});
private void sendMessage() {
// Do something in response to button
Intent intent = new Intent(MainActivity.this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
Log.i("intent","intent is started");
startActivity(intent);
}
它应该有用