Forum Moderators: coopster

Message Too Old, No Replies

Help with my sql and PHP newbie!

         

alchy

1:48 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



Hi I am really new to this please bare with me.
I have a php website that was all setup for me and iI decided after 6 months to move to another domain.

I have registered the domain and all is working. I have uploaded the whole webpage to the new server via ftp in exactly the same paths etc as the old site.

However I do not understand how to initialize my .sql database on the enw server.
I know it's done via cpanel through my sql databases.

I have tried adding it but i get this message come up when i try and access my webpage..

Warning: mysql_pconnect(): Access denied for user: 'victoria_admin@localhost' (Using password: YES) in /home/freeink/public_html/includes/functions/database.php on line 17
Unable to connect to database server!

This is what I have under sql maintenance ...

Connection Strings
Perl $dbh = DBI->connect("DBI:mysql:freeink_victoriashop:localhost","freeink_victoria","<PASSWORD HERE>");
PHP $dbh=mysql_connect ("localhost", "freeink_victoria", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("freeink_victoriashop");

I know my user name and password thats all the info I have if anyone could start with very simple explanation what to do I would be much appreciated:)

Kindest regards David

alchy

1:58 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



Oh here is my public_html/includes/functions/database.php on line 17

<?php
/*
$Id: database.php,v 1.21 2003/06/09 21:21:59 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
[oscommerce.com...]

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;

if (USE_PCONNECT == 'true') {
$$link = mysql_pconnect($server, $username, $password);
} else {
$$link = mysql_connect($server, $username, $password);
}

if ($$link) mysql_select_db($database);

return $$link;
}

function tep_db_close($link = 'db_link') {
global $$link;

return mysql_close($$link);
}

function tep_db_error($query, $errno, $error) {
die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br><br>' . $query . '<br><br><small><font color="#ff0000">[TEP STOP]</font></small><br><br></b></font>');
}

function tep_db_query($query, $link = 'db_link') {
global $$link;

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
}

$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
$result_error = mysql_error();
error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
}

return $result;
}

function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
reset($data);
if ($action == 'insert') {
$query = 'insert into ' . $table . ' (';
while (list($columns, ) = each($data)) {
$query .= $columns . ', ';
}
$query = substr($query, 0, -2) . ') values (';
reset($data);
while (list(, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= 'now(), ';
break;
case 'null':
$query .= 'null, ';
break;
default:
$query .= '\'' . tep_db_input($value) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ')';
} elseif ($action == 'update') {
$query = 'update ' . $table . ' set ';
while (list($columns, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= $columns . ' = now(), ';
break;
case 'null':
$query .= $columns .= ' = null, ';
break;
default:
$query .= $columns . ' = \'' . tep_db_input($value) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ' where ' . $parameters;
}

return tep_db_query($query, $link);
}

function tep_db_fetch_array($db_query) {
return mysql_fetch_array($db_query, MYSQL_ASSOC);
}

function tep_db_num_rows($db_query) {
return mysql_num_rows($db_query);
}

function tep_db_data_seek($db_query, $row_number) {
return mysql_data_seek($db_query, $row_number);
}

function tep_db_insert_id() {
return mysql_insert_id();
}

function tep_db_free_result($db_query) {
return mysql_free_result($db_query);
}

function tep_db_fetch_fields($db_query) {
return mysql_fetch_field($db_query);
}

function tep_db_output($string) {
return htmlspecialchars($string);
}

function tep_db_input($string) {
return addslashes($string);
}

function tep_db_prepare_input($string) {
if (is_string($string)) {
return trim(tep_sanitize_string(stripslashes($string)));
} elseif (is_array($string)) {
reset($string);
while (list($key, $value) = each($string)) {
$string[$key] = tep_db_prepare_input($value);
}
return $string;
} else {
return $string;
}
}
?>


Kindest regards David