Guest Posted March 7, 2006 Posted March 7, 2006 Hi the parse error has moved now i get this :- Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/covermev/public_html/homepage/includes/functions/database.php on line 72 so can some tell me whats wrong with this line $query .= '\'' . tep_db_input($value) . '\', '; So i can hopefully put it right THANKS Andy
kgt Posted March 7, 2006 Posted March 7, 2006 When you get parse errors, they often occur 1 or more lines before the line reported. This is due to the way parsers work. They can't tell there's a problem until they really can't make sense of what's there. Post lines 60-75 of database.php. Contributions Discount Coupon Codes Donations
Guest Posted March 7, 2006 Posted March 7, 2006 When you get parse errors, they often occur 1 or more lines before the line reported. This is due to the way parsers work. They can't tell there's a problem until they really can't make sense of what's there. Post lines 60-75 of database.php. Hi kgt here's lined 60-75 of the database } $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; } } Thanks for your help Andy
kgt Posted March 7, 2006 Posted March 7, 2006 This section looks fine to me. Post the whole file. Contributions Discount Coupon Codes Donations
Guest Posted March 7, 2006 Posted March 7, 2006 Hi kgt here's lined 60-75 of the database } $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; } } Thanks for your help Andy Hi kgt here's the whole file :- <?php /* $Id: database.php,v 1.21 2003/06/09 21:21:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 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 == 'false') { $$link = mysql_pconnect($server, 'covermev_osc2', '6d6APbQCpo'); } else { $$link = mysql_connect($server, 'covermev_osc1', '6d6APbQCpo'); } 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; } } ?> Thanks Andy
kgt Posted March 7, 2006 Posted March 7, 2006 The only difference your file has from the original OSC files is in the connect function. This is the original: if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } This is what you have: if (USE_PCONNECT == 'false') { $$link = mysql_pconnect($server, 'covermev_osc2', '6d6APbQCpo'); } else { $$link = mysql_connect($server, 'covermev_osc1', '6d6APbQCpo'); } Everything else is exactly the same. I cannot see anything syntactically wrong with it. The only thing that is really unusual is why you have changed this line. First off, I'm not sure why you need two different connections based on whether USE_PCONNECT is true or false. I simply cannot imagine why that would be useful. Unless you have modified your configure.php files, USE_PCONNECT will always be either true or false, and never switch. Also, you have "if USE_PCONNECT is false, then mysql_pconnect()". This is a little backwards. It's possible you did this to utilize two database connections on a host that limits queries. If that's the case, you probably want to change the mysql_pconnect() to mysql_connect(). There's nothing about those lines that should cause a syntax error though, and there's nothing on subsequent lines. The only thing I can suggest is copying the contents of this file to another one, deleting database.php, and uploading the new database.php. Contributions Discount Coupon Codes Donations
Guest Posted March 7, 2006 Posted March 7, 2006 The only difference your file has from the original OSC files is in the connect function. This is the original: if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } This is what you have: if (USE_PCONNECT == 'false') { $$link = mysql_pconnect($server, 'covermev_osc2', '6d6APbQCpo'); } else { $$link = mysql_connect($server, 'covermev_osc1', '6d6APbQCpo'); } Everything else is exactly the same. I cannot see anything syntactically wrong with it. The only thing that is really unusual is why you have changed this line. First off, I'm not sure why you need two different connections based on whether USE_PCONNECT is true or false. I simply cannot imagine why that would be useful. Unless you have modified your configure.php files, USE_PCONNECT will always be either true or false, and never switch. Also, you have "if USE_PCONNECT is false, then mysql_pconnect()". This is a little backwards. It's possible you did this to utilize two database connections on a host that limits queries. If that's the case, you probably want to change the mysql_pconnect() to mysql_connect(). There's nothing about those lines that should cause a syntax error though, and there's nothing on subsequent lines. The only thing I can suggest is copying the contents of this file to another one, deleting database.php, and uploading the new database.php. Hi kgt i uploaded a new database and now i get this Warning: mysql_connect(): Access denied for user: 'covermevibe_com@localhost' (Using password: YES) in /home/covermev/public_html/homepage/includes/functions/database.php on line 19 Unable to connect to database server! getting a bit confused here's lines 15 to 20:- if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } i don't see anything wrong with it do you Thanks Andy
kgt Posted March 7, 2006 Posted March 7, 2006 You need to fix your database username and password in includes/configure.php and admin/includes/configure.php with the username and password you were using: $$link = mysql_pconnect($server, 'covermev_osc2', '6d6APbQCpo'); $$link = mysql_connect($server, 'covermev_osc1', '6d6APbQCpo'); One or maybe both of those will work. If USE_PCONNECT in configure.php is true, then use the second one. If it's false, use the first. Contributions Discount Coupon Codes Donations
Guest Posted March 7, 2006 Posted March 7, 2006 You need to fix your database username and password in includes/configure.php and admin/includes/configure.php with the username and password you were using: $$link = mysql_pconnect($server, 'covermev_osc2', '6d6APbQCpo'); $$link = mysql_connect($server, 'covermev_osc1', '6d6APbQCpo'); One or maybe both of those will work. If USE_PCONNECT in configure.php is true, then use the second one. If it's false, use the first. Hi can you tell me where abouts in configure.php do i put these lines. Thanks Andy
Guest Posted March 8, 2006 Posted March 8, 2006 Hi can you tell me where abouts in configure.php do i put these lines.Thanks Andy DID IT THANKS FOR ALL YOUR HELP ANDY
Recommended Posts
Archived
This topic is now archived and is closed to further replies.