我是 PHP 面向对象编程的新手。我有个问题。我写了一个代码,但它不起作用。我知道这很容易,但我想知道它有什么问题。我出现以下错误:
<?php
class connectDB
{
$connection;
$server= "localhost";
$userName = "root";
$password = "";
$select;
$dbName = "profiles";
public function connect()
{
$connection = mysql_connect($server,$userName,$password);
$select = mysql_select_db($dbName,$connection);
}
public function query()
{
$result = mysql_query($query);
if (!$result) {
echo 'Bağlantı Hatası: ' . mysql_error();
exit;
}
}
public function end()
{
mysql_free_result($connection);
}
}
?>
当我尝试在另一个文件中使用它时,我现在遇到了这个错误:(
最佳答案
为什么不使用 MySQLi ?
它简单、强大且准备就绪。
关于php 类——期望,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9307425/