douyu4535 2014-07-21 11:39
浏览 82
已采纳

我的PHP代码的一部分在页面中显示为文本

This is my code.. The problem is that the code after the '>' in if(mysql_affected_rows()>0) id displayed as plain text in the webpage.. Please help..

<?php
session_start();
if( isset( $_POST[reg] ) )
{
    $name = $_POST[n1];
    $age = $_POST[a1];
    $gen = $_POST[r1];
    $phno = $_POST[phno1];
    $email = $_POST[email1];
    $pin = $_POST[pin1];
    $user = $_POST[u1];
    $pas = $_POST[pass];
    $pas1 = $_POST[pass1];
    $i = $_POST[i1];              

    include( "connect.php" );

    $q = "INSERT INTO reg VALUES('0', '$name', '$age', '$gen', '$phno', '$email', '$pin', '$user', '$pas')";
    mysql_query( $q ) or die( mysql_error() );

    if(mysql_affected_rows()>0)
    {
        header("location:index.php");                         
    }
}
?>
  • 写回答

1条回答 默认 最新

  • dongnai6973 2014-07-21 11:40
    关注

    It sounds like your PHP code is not being interpreted at all. If you look at the source code via the browser, do you see a <?php tag in there? This should not happen. If this is the case, your PHP code is not being recognized.

    For example, looking at the source in Firefox, if you see something like this, something is wrong with how PHP is executed: image of PHP code that isn't executed

    Any <?php tag that can be seen in the browser's source code is a problem.


    By the way, be sure to put strings into quotes. You are using things like $_POST[u1] where it should be $_POST["u1"] or $_POST['u1']. Only constants should be used without quotes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?