解析错误:语法错误,在C:\xampp\htdoc \Site\view_category中出现了意外的“mysql_query”(T_STRING)。php在40行

时间:2022-09-08 15:54:44

I'm getting this error 'Parse error: syntax error, unexpected 'mysql_query' (T_STRING) in C:\xampp\htdocs\Site\Site\view_category.php on line 40' in my code but I cannot work out why its there can anyone spot the problem i've googled it and it seems to be just typo's somewhere but i cannot see any problems with my code ?

我得到了这个错误的解析错误:语法错误,C:\xampp\htdocs\网站\view_category中的意外“mysql_query”(T_STRING)。php在第40行,在我的代码中,但是我搞不清楚为什么有人能发现我在谷歌上搜索过的问题,它似乎只是某个地方出现了错误,但是我的代码没有任何问题?

<?php session_start();?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Forum</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<script>var __adobewebfontsappname__="dreamweaver"</script>
<script src="http://use.edgefonts.net/source-sans-pro:n6:default.js" type="text/javascript"></script>

</head>

<body>
<div id="wrapper">
  <header id="top">
    <h1>ITSize</h1>
    <nav id="mainnav">
      <ul>
        <li><a href="Index.html">Home</a></li>
        <li><a href="Fourth Page.html">Register</a></li>
        <li><a href="Second Page.html">Revise</a></li>
        <li><a href="Third Page Page.html">Forum</a></li>
      </ul>
    </nav>
  </header>
  <article id="main">
  <br>
  <br>
 <?php 
 include_once("DBconnect.php");
 $cid= $_GET['cid'];

 if (isset($_SESSION['uid'])){
     $logged= " | <a href='create_topic.php?cid=".$cid.">Click here to create a topic<a>";
 }else{
     $logged = " | Please log in to create topics in this forum";
 }

 $sql = "SELECT id FROM categories WHERE id='".$cid."' LIMIT 1";
 $res mysql_query($sql) or die(mysql_error());
 if (mysql_num_rows($res) ==1){
 }
 else{
     echo "<a href='Forum.php'>Return To Forum Page</a><br><br>";
     echo"<p> You are trying to view a category that does not exist";
 }

 ?>

 </article>
  <aside id="sidebar">


</aside>
  <footer><a href="Third Page.html">My Account</a>
  </footer>
</div>
</body>
</html>

2 个解决方案

#1


2  

you are missing '=' sign

你少了'='符号

$res = mysql_query($sql) or die(mysql_error());

#2


0  

You forgot the = sign on

你忘了签到

$res mysql_query($sql) or die(mysql_error());

change it to

将其更改为

$res = mysql_query($sql) or die(mysql_error());

#1


2  

you are missing '=' sign

你少了'='符号

$res = mysql_query($sql) or die(mysql_error());

#2


0  

You forgot the = sign on

你忘了签到

$res mysql_query($sql) or die(mysql_error());

change it to

将其更改为

$res = mysql_query($sql) or die(mysql_error());