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条)

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答