这是我的代码.. 问题是 if(mysql_affected_rows()>0) id 中 '>' 之后的代码在网页中显示为纯文本.. 请帮忙..
<?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");
}
}
?>
最佳答案
听起来您的 PHP 代码根本没有被解释。如果您通过浏览器查看源代码,您会看到 <?php
吗?标签在那里?这不应该发生。如果是这种情况,则无法识别您的 PHP 代码。
例如,查看 Firefox 中的源代码,如果您看到类似这样的内容,则说明 PHP 的执行方式有问题:image of PHP code that isn't executed
任何<?php
可以在浏览器源代码中看到的标记是一个问题。
对了,一定要把字符串放在引号里。您正在使用类似 $_POST[u1]
的东西它应该在哪里 $_POST["u1"]
或 $_POST['u1']
.只有constants应该不带引号使用。
关于php - 我的部分 PHP 代码在页面中显示为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24864188/