【问题标题】:MySQL and PHP. My table doesnt existMySQL 和 PHP。我的表不存在
【发布时间】:2017-03-12 05:40:07
【问题描述】:

所以我在我的 phyMyAdmin 中创建了一个数据库,并使用我的 html 文件对其进行编码并在 chrome 中打开它......它说 表 'forum.form_tabl' 不存在 发生了什么事,我该怎么办? 这是代码

    <?php

session_start();
require"db_connect.php";
$sql= "SELECT forum_id,forum_name FROM form_tabl";

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<div id="container">
	<table>
		<?php if($query->num_rows !==0);
		while($row = $query->fetch()):
		?>
		<tr><td><a href="forum.php"?id = <?php echo $forum_id?>"><?php echo $f_name;?></a>
			</td></tr>
			<?php endwhile;T_ENDIF;
		?>
	</table>
</div>


</body>
</html>[enter image description here][1]
    //THE OTHER .PHP file is db_connect.php where i put the actual one

    <?php

    $db = mysqli_connect("localhost","root","","forum") or die("ERROR! With Connection")
    ?>

enter image description here

【问题讨论】:

  • 你能告诉我具体的问题吗?因为您似乎正在使用 prepare() 并且再次尝试使用 mysqli 建立数据库连接
  • 检查您的表格名称。并正确定义您的问题
  • @PramodKharade 已编辑,提前谢谢您
  • @MohitYadav 当我在浏览器中打开它时,它说表 'forum.form_tabl' 不存在 注意:试图在 C:\xampp\htdocs\newsite\form 中获取非对象的属性。第 26 行的 php 致命错误:在第 27 行调用 C:\xampp\htdocs\newsite\form.php 中非对象的成员函数 fetch()
  • 删除 db_connect.php 文件并参考下面将放置在 ans 中的代码。

标签: php html mysql xampp dreamweaver


【解决方案1】:
$con = mysqli_connect("HostName","UserName","password","DBName") or die("Some error occurred during connection " . mysqli_error($con));  

// Write query

$strSQL = "SELECT username FROM MyTable";

// Execute the query.

$query = mysqli_query($con, $strSQL);
while($result = mysqli_fetch_array($query))
{
  echo $result["username"]."
";
}

// Close the connection
mysqli_close($con);

?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    • 2017-02-25
    • 1970-01-01
    • 2014-11-05
    • 1970-01-01
    • 2011-08-16
    • 2011-11-05
    相关资源
    最近更新 更多