doushun1870 2014-05-19 06:05
浏览 49

插入mysql时未定义的变量

I'm getting an undefined variable when trying to execute my code, the entry gets made in mysql but there is no data being inserted, obviously because of the undefined variable.

It was working...

Here's the message:

PHP Notice:  Undefined variable: title in /Applications/MAMP/htdocs/rfx/wp-content/plugins/rfx-manager/inc/rfi_page.php on line 154

Here is the code:

    <?php
    $wpdb->query("insert into ".$wpdb->prefix."forms set user_id=".$user_id.",
        title='".$title."');

    $title=$result->title;
    ?>

<form method="post" enctype="multipart/form-data" role="form">

<label for="title"><b>Enter title here:</b></label>
    <br>
    <input type="text" name="title" class="large-text" value="<?php echo (isset($title) ? $title : '') ?>" placeholder="Enter title">

    <input class="button-primary" type="submit" name="submit" value="<?php _e( 'Submit RFI for approval' ); ?>" />
</form>
  • 写回答

1条回答 默认 最新

  • dongsheng1238 2014-05-24 09:01
    关注

    Sorry guys, basically what the problem was is that one of the variables wasn't of course declared.

    The snippet I gave was this:

    $title=$result->title;

    There were more variables like this stacked, one of them was giving a conflict, I basically went through them one by one adding each one and testing it, that surfaced the issue.

    Hope this helps anyone.

    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入