Đã Đóng

Adapt short script to new server needs

I need to get some modification to a script so that it works on my new server.

The script it very simple, it takes names of recent posts in Wordpress database to show it up, using PHP.

Whereas the script was working flawlessly up-to-now, I now get this error:

--------------

Warning: mysqli_real_connect() [function.mysqli-real-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/tmp/[url removed, login to view]' (2) in /export/sd202/www/jp/r/e/.../includes/[url removed, login to view] on line 65

Fatal error: Call to undefined function report_error() in /export/sd202/www/jp/r/e/.../includes/[url removed, login to view] on line 66

--------------

which seems to refer to a connection error due to wrong password or so, though I'm using the same settings (host, db name, user , password) on my wordpress installation and it works perfectly.

Here is the content of [url removed, login to view] file:

<?php

class Database_Connection

{

/* PUBLIC METHODS */

public function __construct()

{

$this->db = mysqli_init();

$this->connected = false;

}

public function query($sql)

{

$this->ensure_db_connection();

$res = $this->db->query($sql)

or report_error("Error while processing the request.", "Bad SQL statement: $sql<br><br>" . $this->db->error, true);

return $res;

}

public function stmt_init()

{

$this->ensure_db_connection();

return $this->db->stmt_init();

}

public function real_escape_string($query)

{

$this->ensure_db_connection();

return $this->db->real_escape_string($query);

}

public function close()

{

if ($this->connected)

{

$this->db->close();

$this->connected = false;

}

}

/* PROPERTIES */

public function __get($var)

{

if ($var == "affected_rows")

{

$this->ensure_db_connection();

return $this->db->affected_rows;

}

elseif ($var == "insert_id")

{

$this->ensure_db_connection();

return $this->db->insert_id;

}

}

/* PRIVATE IMPLEMENTATION */

private $db;

private $connected;

private function connect()

{

mysqli_real_connect($this->db, CONFIG_DB_SERVER, CONFIG_DB_USER, CONFIG_DB_PASSWORD, CONFIG_DB_NAME)

or report_error("Unable to connect to the database", mysqli_connect_error(), true);

$this->db->query('SET NAMES utf8')

or report_error("Unable to connect to the database", "Impossible to change character encoding", true);

}

public function ensure_db_connection()

{

if (! $this->connected)

{

$this->connect();

$this->connected = true;

}

}

}

?>

Kỹ năng: MySQL, PHP

Xem thêm: wordpress database settings, sql r, r sql, new server, socket server, short script, mysqli, modification php script, fatal, db query, sql user export, mysql export character, script warning, mysql change connection, script refer, wordpress fatal error, mysql connection query, due fatal error, php script mysql export, server 2012 wordpress, mysql script utf8, wordpress query script, export mysql wordpress, mysql wordpress database export, function call wordpress

Về Bên Thuê:
( 13 nhận xét ) Nara, Japan

Mã Dự Án: #1681300

5 freelancer đang chào giá trung bình $107 cho công việc này

gslogics123

Respected Sir Ready to start. i can fix in 1 hour. Please check the message box. Regards Ashwin

$45 USD trong 0 ngày
(180 Đánh Giá)
7.1
Bistechsupport

Hi, This is Jeni from bistech support. We would like to inform you that we could able to develop this project. Please find the attached document for your reference. our ball park quote is 100 USD. Word Thêm

$100 USD trong 7 ngày
(18 Đánh Giá)
4.4
michaelzhang80

Please see the private message I sent to you, thanks.

$40 USD trong 2 ngày
(0 Đánh Giá)
0.0
T2Os4a0IH

Custom Software Development - <b><i>Removed by Admin</i></b>

$250 USD trong 1 ngày
(0 Đánh Giá)
0.0
sascoms

Quick Fix by both a system administrator and experienced web developer.

$100 USD trong 0 ngày
(0 Đánh Giá)
0.0