Configuring an e-store to a website!! Mysql err!!
01-03-2010, 05:55 PM
|
Configuring an e-store to a website!! Mysql err!!
|
Posts: 14
Name: Kevin
|
Hello,
I am configuring a new e-store to my website. The installation and configuration was successful! But when I try t ogo to administration tool, then it says
Code:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /www/example.com/e/x/a/example/htdocs/e-store/estore/catalog/admin/includes/functions/database.php on line 45 0 -
select configuration_key as cfgKey, configuration_value as cfgValue from configuration
[TEP STOP]
This is the database.php code:
Code:
<?php
function tep_db_connect($server = 'example.com', $username = 'example', $password = 'xxxxxx', $database = 'database_example', $link = 'link_example') {
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, $logger;
if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
if (!is_object($logger)) $logger = new logger;
$logger->write($query, 'QUERY');
}
$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());
if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
if (mysql_error()) $logger->write(mysql_error(), 'ERROR');
}
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_result($result, $row, $field = '') {
return mysql_result($result, $row, $field);
}
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($link = 'db_link') {
global $$link;
return mysql_insert_id($$link);
}
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, $link = 'db_link') {
global $$link;
if (function_exists('mysql_real_escape_string')) {
return mysql_real_escape_string($string, $$link);
} elseif (function_exists('mysql_escape_string')) {
return mysql_escape_string($string);
}
return addslashes($string);
}
function tep_db_prepare_input($string) {
if (is_string($string)) {
return trim(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;
}
}
?>
I don't know what's wrong on line 45. Please help! I am so confused.  .
Thanks.
keva
|
|
|
|
01-03-2010, 06:18 PM
|
Re: Configuring an e-store to a website!! Mysql err!!
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
In itself, there is nothing wrong on line 45, if your connection to the DB server is ok.
Chances are, that the connection is not ok, so, when a query is sent to the server, the conenctor, or the piece that serves as a gateway between PHP and mysql returns an error.
Now, it looks like this code don't check to see if an error is returned upon a query.
So, when it tries to parse the query result, as there was no result but an error, it tells you
Quote:
|
supplied argument is not a valid MySQL-Link resource
|
Those are just suppositions, but they might fit your situation.
First thing, can you connect to your database?
Second, does your script tells you that the database connection could be established, or anything like that.
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
01-03-2010, 06:32 PM
|
Re: Configuring an e-store to a website!! Mysql err!!
|
Posts: 14
Name: Kevin
|
thanks tripy!
yes i think i can because it says connection to database succesful. database import succesful. well, this is a free hosting. might that be the problem because on some page there is a script that says "Warning: session_save_path(): SAFE MODE Restriction in effect....."
thanks!
|
|
|
|
01-03-2010, 06:33 PM
|
Re: Configuring an e-store to a website!! Mysql err!!
|
Posts: 14
Name: Kevin
|
do you guys think that this is right?: "... function tep_db_connect($server = 'www.example.com', $username = 'example', $password = 'xxxxxx', $database = 'database_example', $link = 'link_example') {
global $$link;..."
|
|
|
|
01-03-2010, 09:32 PM
|
Re: Configuring an e-store to a website!! Mysql err!!
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Yep.
What you see here is the definition of a function, with the list of parameters, and the default values if nothing is provided when you call that function.
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
01-04-2010, 09:48 AM
|
Re: Configuring an e-store to a website!! Mysql err!!
|
Posts: 14
Name: Kevin
|
OK! so do I have to have these: cURL; OpenSSL
I know the ssl but i don't know the cURL
thanks
|
|
|
|
|
« Reply to Configuring an e-store to a website!! Mysql err!!
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|