Fermé

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;

}

}

}

?>

You get the files you need and I'm making the change on it.
No direct access to cPanel or FTP account for security reasons.

Compétences : MySQL, PHP

Voir plus : wordpress database settings, sql r, sql in r, r sql, to new server, t-short, socket server c, short script, mysqli, modification to 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

Concernant l'employeur :
( 13 commentaires ) Nara, Japan

N° du projet : #1681300

5 freelance ont fait une offre moyenne de 107 $ pour ce travail

gslogics123

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

45 $ USD en 0 jours
(180 Commentaires)
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 Plus

100 $ USD en 7 jours
(18 Commentaires)
4.4
michaelzhang80

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

40 $ USD en 2 jours
(0 Commentaires)
0.0
T2Os4a0IH

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

250 $ USD en 1 jour
(0 Commentaires)
0.0
sascoms

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

100 $ USD en 0 jours
(0 Commentaires)
0.0