I first run the PHP site locally, the environment has been well-matched, the database is also in, the IIS browsing error, pop up a prompt box, ". $str."
The mistake is this paragraph. There is no great God help to see.
Public Function show_error ($message = ', $sql = ') {
echo " ";
echo " error message Tip:
";
echo "";
Echo ' Error reason: '. Mysql_error (). "
";
echo "";
echo "". $message. "";
echo "";
echo "
" . $sql. "
";
echo "";
echo " ";
}
Reply to discussion (solution)
Code to stick it out ....
Code to stick it out ....
Can you help me with a look? Had a morning of this problem.
You take a picture and look at it, it's not where you think it's going.
Take your piece of code and see if your error message doesn't clearly point to the wrong place.
Take your piece of code and see if your error message doesn't clearly point to the wrong place.
This is the code of the database connection!
Class mysql{
Private $db _host;
Private $db _user;
Private $db _pwd;
Private $db _database;
Private $conn;
Private $sql;
Private $result;
Private $coding;
Private $show _error = true;
Public function __construct ($db _host= "localhost", $db _user= "root", $db _pwd= "admin", $db _database= "Likang", $coding = ' Utf-8 ') {
$this->db_host = $db _host;
$this->db_user = $db _user;
$this->db_pwd = $db _pwd;
$this->db_database = $db _database;
$this->coding = $coding;
$this->connect ();
}
Private Function Connect () {
$this->conn = @mysql_connect ($this->db_host, $this->db_user, $this->db_pwd);
if (! $this->conn) {
if ($this->show_error) {
$this->show_error (' ERROR hint: Link database failed! ');
}
}
if (! @mysql_select_db ($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error (' ERROR hint: Open database failed! ');
}
}
if (! @mysql_query ("SET NAMES $this->coding")) {
if ($this->show_error) {
$this->show_error (' ERROR warning: setting encoding failed! ');
}
}
}
Public Function Query ($sql) {
$this->sql = $sql;
$result = mysql_query ($this->sql, $this->conn);
if (! $result) {
$this->show_error (' Wrong SQL statement: ', $this->sql);
}else{
return $this->result = $result;
}
}
Public Function Close ()
{
return Mysql_close ();
}//Close database connection
Public Function show_databases () {
$this->query ("Show Databases");
Echo ' Existing database: '. Mysql_num_rows ($this->result);
echo "
";
$i = 1;
while ($row =mysql_fetch_array ($this->result)) {
echo "$i $row [Database]". "
";
$i + +;
}
}
Public Function Show_tables () {
$this->query ("Show Tables");
echo "Database {$this->db_database} is common." Mysql_num_rows ($this->result). "Zhang table:";
echo "
";
$column _name = "Tables_in_". $this->db_database;
$i = 1;
while ($row =mysql_fetch_array ($this->result)) {
echo "$i $row [$column _name]". "
";
$i + +;
}
}
Public Function Fetch_array ($result = ") {
if ($this->result) {
Return mysql_fetch_array ($this->result);
}else{
return mysql_fetch_array ($result);
}
}
Public function FindAll ($table, $field = ' * ') {
return $this->query ("Select $field from $table");
}
Public Function Delete ($table, $condition) {
return $this->query ("DELETE from $table WHERE $condition");
}
Public Function Insert ($table, $field, $value) {
$i = $this->query ("INSERT into $table ($field) VALUES (' $value ')");
return $i;
}
Public Function Update ($table, $update _content, $condition) {
echo "UPDATE $table SET $update _content WHERE $condition";
return $this->query ("UPDATE $table SET $update _content WHERE $condition");
}
Public Function insert_id () {
return mysql_insert_id ();
}
Public Function num_rows () {
if ($this->result = = null) {
if ($this->show_error) {
$this->show_error (' SQL statement error ', ' Check to see if the query () method is already in use and query successfully and return the resource identifier? ');
}
} else {
Return mysql_num_rows ($this->result);
}
}
Public Function Num_fields ($table) {
$this->query ("SELECT * from $table");
echo "
";
Echo ' Number of fields: '. $total = Mysql_num_fields ($this->result);
echo "
";
for ($i = 0; $i < $total; $i + +) {
Print_r (Mysql_fetch_field ($this->result, $i));
}
echo "
";
echo "
";
}
Public Function show_error ($message = ', $sql = ') {
echo " ";
echo " error message Tip:
";
echo "";
Echo ' Error reason: '. Mysql_error (). "
";
echo "";
echo "". $message. "";
echo "";
echo "
" . $sql. "
";
echo "";
echo " ";
}
}
?>
You take a picture and look at it, it's not where you think it's going.
When I clicked on index.php, it came out with the code for the database connection and two attached pop-up windows. "$str.", the back of the pop-up window is the code I posted, which shows red.
Public Function show_error ($message = ', $sql = ') {
echo "
";
echo " error message Tip:
";
echo "";
Echo ' Error reason: '. Mysql_error (). "
";
echo "";
echo "". $message. "";
echo "";
echo "
" . $sql. "
";
echo "";
echo " ";
Click OK to show that the page cannot be found.
This is a PHP configuration environment does MySQL have any value related to this? WordPress phpMyAdmin all installed in these places are no problem.