重申和使用mysqli_insert_id()的返回类型有什么问题?

时间:2019-06-28 20:00:41

标签: php mysql

此行显示错误:

$query1="UPDATE `users` 
         SET password=''.md5(md5(mysqli_insert_id($link).$pass)).'' 
         WHERE id=''.mysqli_insert_id($link).'' ";

错误如下:

  

可恢复的致命错误:mysqli类的对象无法转换为字符串       在第30行的/home/vhosts/nagarajhegde41.freevar.com/DiaryHome.php中

1 个答案:

答案 0 :(得分:2)

您依靠string parsing在文本中执行代码,但是语法不正确。我的建议是您甚至不要尝试。至少可以说,将代码打包在字符串中并不方便。只要看看使用常规代码语句有多容易:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<body>
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
    <div id="player"></div>

    <script>
        // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');

      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          width: '100%',
          videoId: 'M7lc1UVf-VE',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }

      // 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
        event.target.playVideo();
      }

      // 5. The API calls this function when the player's state changes.
      //    The function indicates that when playing a video (state=1),
      //    the player should play for six seconds and then stop.
      var done = false;
      function onPlayerStateChange(event) {
        if (event.data == YT.PlayerState.PLAYING && !done) {
          setTimeout(stopVideo, 6000);
          done = true;
        }
      }
      function stopVideo() {
        player.stopVideo();
      }
    </script>
</body>

</html>

通过这种方式免费获得

  • 更简单的语法。
  • 可读代码。
  • 在所有PHP编辑器(甚至是免费的)中正确显示语法并完成代码。
  • 正确的错误报告以及有用的行号信息。
  • 对SQL注入的保护。

P.S。您可能要检查Password Hashing Functions