Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySql/PHP论坛选择要查看的论坛时出现问题_Php_Html_Mysql_Phpmyadmin_Mysql Error 1064 - Fatal编程技术网

MySql/PHP论坛选择要查看的论坛时出现问题

MySql/PHP论坛选择要查看的论坛时出现问题,php,html,mysql,phpmyadmin,mysql-error-1064,Php,Html,Mysql,Phpmyadmin,Mysql Error 1064,我有两个文件fourm.php和viewfourm.php <?php $host="mysql13.000webhost.com"; // Host name $username="a2670376_Users"; // Mysql username $password="PASS"; // Mysql password $db_name="a2670376_Pass"; // Database name $tbl_name="fourm"; // Table na

我有两个文件fourm.php和viewfourm.php

 <?php

 $host="mysql13.000webhost.com"; // Host name 
 $username="a2670376_Users"; // Mysql username 
 $password="PASS"; // Mysql password 
 $db_name="a2670376_Pass"; // Database name 
 $tbl_name="fourm"; // Table name 

   // Connect to server and select database.
   mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
   mysql_select_db("$db_name")or die("cannot select DB");

    // select record from mysql 
   $sql="SELECT * FROM $tbl_name";
   $result=mysql_query($sql);
   ?>
  <table>
  <tr>
  <td align="center"><strong>Post Number</strong></td>
 <td align="center"><strong>UserName</strong></td>
 <td align="center"><strong>Topic</strong></td>
 <td align="center"><strong>Date</strong></td>
 <td align="center"><strong>View</strong></td>
 </tr>
 <?php
 while($rows=mysql_fetch_array($result)){
 ?>
 <tr>
 <td><? echo $rows['fourmid']; ? >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
 <td><? echo $rows['username']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['fourmname']; ?   >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['date']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="fourm.php">back/a></td>
<?php
 // close while loop 
 }
 ?>

</tr>
</table>
<?php
// close connection; 
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>
fourm.php优先

<?php

$host="mysql13.000webhost.com"; // Host name 
$username="a2670376_Users"; // Mysql username 
$password="PASS"; // Mysql password 
$db_name="a2670376_Pass"; // Database name 
$tbl_name="fourm"; // Table name 

  // Connect to server and select database.
 mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
 mysql_select_db("$db_name")or die("cannot select DB");

  // select record from mysql 
  $sql="SELECT * FROM $tbl_name";
  $result=mysql_query($sql);
 ?>
<table>
<tr>
<td align="center"><strong>Post Number</strong></td>
<td align="center"><strong>UserName</strong></td>
<td align="center"><strong>Topic</strong></td>
<td align="center"><strong>Date</strong></td>
<td align="center"><strong>View</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['fourmid']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['username']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['fourmname']; ?   >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['date']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="viewfourm.php?id=<? echo $rows['fourmid']; ?>">View Topic</a></td>
<?php
 // close while loop 
 }
 ?>

</tr>
</table>
<?php
// close connection; 
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>
现在查看fourm.php

 <?php

 $host="mysql13.000webhost.com"; // Host name 
 $username="a2670376_Users"; // Mysql username 
 $password="PASS"; // Mysql password 
 $db_name="a2670376_Pass"; // Database name 
 $tbl_name="fourm"; // Table name 

   // Connect to server and select database.
   mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
   mysql_select_db("$db_name")or die("cannot select DB");

    // select record from mysql 
   $sql="SELECT * FROM $tbl_name";
   $result=mysql_query($sql);
   ?>
  <table>
  <tr>
  <td align="center"><strong>Post Number</strong></td>
 <td align="center"><strong>UserName</strong></td>
 <td align="center"><strong>Topic</strong></td>
 <td align="center"><strong>Date</strong></td>
 <td align="center"><strong>View</strong></td>
 </tr>
 <?php
 while($rows=mysql_fetch_array($result)){
 ?>
 <tr>
 <td><? echo $rows['fourmid']; ? >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
 <td><? echo $rows['username']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['fourmname']; ?   >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['date']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="fourm.php">back/a></td>
<?php
 // close while loop 
 }
 ?>

</tr>
</table>
<?php
// close connection; 
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>

现在在forum.php上,当我从MySql数据库中选择要查看的论坛时,它加载了我要修复的所有论坛,我知道它为什么这么做,原因是它的脚本与第一个相同,只是修改了一点,但我做了我能做的。我正在MySql数据库中选择forum s Throue fourmid标记,这就是>查看主题的内容,它应该使用viewfourm.php中选择的id加载论坛。修改您的sql查询$sql=SELECT*FROM$tbl\u name;像这样

$fourmid=$_POST['fourmid']//如果使用get方法传递,则使用$_get['fourmid']; $sql=从$tbl_名称中选择*其中fourmid='$fourmid'

还必须将fourmid从fourm.php传递到viewfourm.php

 <?php

 $host="mysql13.000webhost.com"; // Host name 
 $username="a2670376_Users"; // Mysql username 
 $password="PASS"; // Mysql password 
 $db_name="a2670376_Pass"; // Database name 
 $tbl_name="fourm"; // Table name 

   // Connect to server and select database.
   mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
   mysql_select_db("$db_name")or die("cannot select DB");

    // select record from mysql 
   $sql="SELECT * FROM $tbl_name";
   $result=mysql_query($sql);
   ?>
  <table>
  <tr>
  <td align="center"><strong>Post Number</strong></td>
 <td align="center"><strong>UserName</strong></td>
 <td align="center"><strong>Topic</strong></td>
 <td align="center"><strong>Date</strong></td>
 <td align="center"><strong>View</strong></td>
 </tr>
 <?php
 while($rows=mysql_fetch_array($result)){
 ?>
 <tr>
 <td><? echo $rows['fourmid']; ? >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
 <td><? echo $rows['username']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['fourmname']; ?   >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><? echo $rows['date']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="fourm.php">back/a></td>
<?php
 // close while loop 
 }
 ?>

</tr>
</table>
<?php
// close connection; 
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>
编辑

做一个这样的链接


在form.php中,从

a href="viewfourm.php?id=<? echo $rows['fourmid']; ?>">View Topic</a>
//viewform.php

$fourmid=$_请求['id']

$sql=从$tbl_名称中选择*,其中fourmid='$fourmid'


试试看..

sql vurnurable我知道我会在以后解决这个问题。它们不再得到维护,并且已经开始使用。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果你选择PDO,.MySQLi我仍在学习MySql和php lol我将了解下一步,但对我来说,MySql更容易,也不使用空格对齐。警告:MySql_fetch_数组:提供的参数不是有效的MySql结果资源,位于/home/a2670376/public_html/fourms/viewfourm.php的第35行,我得到了这个,我对脚本做了这个操作//从MySql$fourmid选择记录=$_POST['fourmid']//如果使用get方法传递,则使用$_get['fourmid']$sql=从$tbl_名称中选择*其中fourmid='$fourmid';在fourm.php中为每个主题创建一个链接,直到它不起作用为止我不理解你的意思或者它不起作用警告:mysql_fetch_数组:提供的参数不是第34行/home/a2670376/public_html/fourms/viewfourm.php中的有效mysql结果资源