简体   繁体   English

浏览器显示整个php代码

[英]Browser is showing the entire php code

I am new to PHP. 我是PHP新手。 This is my code: 这是我的代码:

$con_cursuri=mysqli_connect("localhost","root","","proiect");
$date = date('Y-m-d H:i:s');
$usid=$_SESSION['id'];

$result = mysqli_query($con_cursuri,"SELECT * FROM cursuri INNER JOIN subiecte ON      idSubiecte= Subiecte_idSubiecte");


while($row = mysqli_fetch_array($result))
{
echo "<table border=1><form action='cursuri.php' method='POST'> <br><tr><td width=290px ><a href=".$row['link'].">".$row['nume_curs']."</a></td><td width=290px>".$row['descriere_curs']."</td></tr>".$row['nume_subiect']."<td width=290px><input type=hidden name=id value=".$row['idCursuri']."><input type=submit name=submit value='Inrolare curs!'></form></td>
<br>";

}

$submit=$_POST['submit'];  
$id_curs=$_POST['id'];

if($submit)
{
$inrolare_curs = mysqli_query($con_cursuri,"INSERT INTO inrolare_curs VALUES('', '$usid', '$date', '', '$id_curs')") ;  
}

Any sugestions? 有任何建议吗?

PS: yesterday, the page worked. PS:昨天,该页面有效。 I reinstalled xampp, but the result is the same. 我重新安装了xampp,但是结果是一样的。

check the followings: 检查以下内容:

  • <?php is at the start of the script <?php是脚本的开头
  • the file extension should be .php (by default) 文件扩展名应为.php (默认情况下)
  • check if php is enabled in your apache configurations: this and this 检查您的apache配置中是否启用了php: thisthis
  • use a sample script to check if php is working: <?php echo "hello world"; ?> 使用示例脚本检查php是否正常工作: <?php echo "hello world"; ?> <?php echo "hello world"; ?>
  • install another tool like xampp (example: ampps) 安装其他工具,例如xampp(示例:ampps)

Also take a look to this answer: Apache is downloading php files instead of displaying them 还要看看这个答案: Apache正在下载php文件而不是显示它们

I think you have not used the start and end tag of php ie, 我认为您尚未使用php的开始和结束标记,即

<?php
//your code goes here
?>

Rather you are using the short tags and it is not enabled as answered by @john conde 而是您使用的是短标签,并且未按@john conde的回答启用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM