mysqli_connect()期望参数2为字符串

时间:2016-04-03 16:26:28

标签: php mysqli php-mysqlidb

  

警告:mysqli_connect()期望参数2是字符串,对象   在第56行第56行的C:\ wamp \ www \ social \ includes \ acceso.php中给出:

mysqli_connect($database_conexionredsocial, $conexionredsocial);
  

警告:mysqli_query()期望参数1为mysqli,给定字符串   在第61行第61行的C:\ wamp \ www \ ksocial \ includes \ acceso.php

$LoginRS = mysqli_query($LoginRS__query, $conexionredsocial) or die(mysql_error());

我需要帮助。如果有人带来解决方案,我将非常感激。

3 个答案:

答案 0 :(得分:0)

corresponding manual page上可以看到,mysqli_query()函数接受字符串参数。在发送对象时。

很可能你有一个多余的mysqli_connect调用,发送一个现有的连接。所以,摆脱

mysqli_connect($database_conexionredsocial, $conexionredsocial);

答案 1 :(得分:0)

你需要传递3个参数,解决方法是:

查询语法为:

mysqli_query(connection,query,resultmode);

PHP

$LoginRS = mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries 
mysqli_query($LoginRS,"SELECT * FROM Persons");
mysqli_query($LoginRS,"INSERT INTO Persons (FirstName,LastName,Age) 
VALUES ('Glenn','Quagmire',33)");

mysqli_close($LoginRS);

答案 2 :(得分:-1)

Create a PHP file with your connection variables:

<?php
$DBHost = "host";
$DBUser = "user";
$DBPass = "pass";
change your connection file to this:

<?php
require("connectionsettings.php");
$connection = mysqli_connect($DBHost, $DBUser, $DBPass);
if (!$connection) {
    die('Connect Error: ' . mysqli_connect_error());
}