doulai2025 2014-04-28 11:21
浏览 61
已采纳

警告:mysqli_error()只需要1个参数,在[重复]中给出0

This question already has an answer here:

I am following this tutorial here and trying to do exactly as it is explained there. I am though getting an error:

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /storage/content/37/191037/website.se/public_html/newsite/admin/perfis/index.php on line 12

And here is the code:

<?php

session_start();
require_once "scripts/conector.php";
// Determine which page ID to use in our query below -----------------------------------------------------------------------------------
if (!$_GET['pid']) {
    $pageid = '1';
} else {
    $pageid = ereg_replace("[^0-9]", "", $_GET['pid']); // filter everything but numbers for security
}
// Query the body section for the proper page
$sqlCommand = "SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $body = $row["pagebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Query the module data for display ---------------------------------------------------------------------------------------------------------------
$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='footer' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $footer = $row["modulebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Query the module data for display ---------------------------------------------------------------------------------------------------------------
$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='custom1' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $custom1 = $row["modulebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Build Main Navigation menu and gather page data here -----------------------------------------------------------------------------
$sqlCommand = "SELECT id, linklabel FROM pages WHERE showing='1' ORDER BY id ASC"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 

$menuDisplay = '';
while ($row = mysqli_fetch_array($query)) { 
    $pid = $row["id"];
    $linklabel = $row["linklabel"];

    $menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />';

} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
//mysqli_close($myConnection); 
?>

<?php echo $menuDisplay; ?>

I don't understand what am I doing wrong. The database is working well, I have inserted data manually and it worked and I also use the same database to have a log-in mechanism and it is also working fine.

Can somebody spot the error?

</div>
  • 写回答

2条回答 默认 最新

  • dongmin1166 2014-04-28 11:24
    关注

    Change

    die (mysqli_error()); 
    

    to

    die('Error: ' . mysqli_error($myConnection));
    

    in the query

    $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 MIT控制器能控制不稳定系统吗
  • ¥15 公司代码X对业务伙伴X无效,处理方法?
  • ¥15 微信内链接跳转到浏览器打开怎么实现
  • ¥15 三角波可以直接加施密特电路整形到矩形波吗实物
  • ¥15 html,php,在使用html请求php文件时发生了错误,无法请求到php文件读取数据库并用javascript进行数据显示,刷新
  • ¥15 touchsocket udp组播
  • ¥20 MAC怎么安装Silverlight 插件?以及安装了怎么启用
  • ¥15 VS2012中查询语句无法填入解析,数值传不进去
  • ¥15 gis系统开发出现命名空间“ESRI.ArcGIS”中不存在类型或命名空间名“Analyst3D”报错
  • ¥15 怎么让ai定时给我发信息 c#或者python