Link to home
Start Free TrialLog in
Avatar of wood1e
wood1e

asked on

website not working, connecting to database

Hi,

Just wondering if someone could point me in the right direction as to why my website is not connecting to the database.  

I have changed the config file to match the db name, password etc.  But the webiste is not connecting!!  Is there something else I need to change?

URL attached below.
URL.txt
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Turn on error checking by adding this to the  start of your script

<?php
ini_set('display_errors', 1); error_reporting(E_ALL);

and see what messages you get. Alternatively check the error logs. Another alternative is to add a die clause to the mysql_ commands like so

mysql_connect(.......data.....) or die( "Error - " . mysql_error() );

Avatar of wood1e
wood1e

ASKER

I have added to the top of my settings.php file, FTP'd and refreshed but nothing happened?

And I think there die settings throughout the pages.
I cannot see any usefull erros from that URL.

Can you post your code snippets, then we could assist by giving you examples of making db errors verbose in order to debug.
Avatar of wood1e

ASKER

Ok what code would you need I have attached the config.php without certain informaiton obviously. :)

<? 

   session_start();
   error_reporting(5);
   
   // TIME & DATE
   $today               = getdate(time());
   $date             = $today['weekday'].", ".$today['month']." ".$today['mday'];
   $date_database       = $today['year']."-".$today['mon']."-".$today['mday']." ".$today['hours'].":".$today['minutes'].":".$today['seconds'];
   
   $date_year           = $today['year'];
   $date_mon            = $today['mon']; if ($date_mon < 10) {$date_mon = "0$date_mon";}
   $date_mday           = $today['mday']; if ($date_mday < 10) {$date_mday = "0$date_mday";}
   
   $date_day            = $today['weekday'];
   $date_month          = $today['month'];
   $time             = time();
   
   $monthname           = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
   $monthname2          = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
   $date_today          = $date_mday."-".$monthname2[$date_mon-1]."-".$date_year;
   $date_today_time     = $date_mday."-".$monthname2[$date_mon-1]."-".$date_year. " / " .$today['hours'].":".$today['minutes'].":".$today['seconds'];
   $date_name           = $date_mday." ".$date_month." ".$date_year;
   
   
   
   
   // DATABASE SETTING
   $db_host          = "mysql1.DB.net";
   $db_name          = "dbname";
   $db_username         = "username";
   $db_password         = "password";
   
   
   
   
   // EMAIL SETTING
   $smtp_server         = "smtp.synaxissolutions.co.uk";
   $smtp_username       = "info@synaxissolutions.co.uk";
   $smtp_password       = "password";
   $smtp_auth           = true;
   
   $email_from          = "info@mywesbite.co.uk";
   $email_from_name     = "mywebsite";
   $email_wordwrap         = 50;
   
   
   
   
   // ROWS SETTING
   $admin_rows          = 3;
   $delivery_charge_rows   = 9;
   $product_price_rows     = 7;
   
   

   
   // ADMIN EMAIL
   $admin_email         = "website<info@mywesbite.co.uk>";
   
   
   
   
   // DIRECTORY & URL SETTING
   $dir_base            = "$DOCUMENT_ROOT";
   $url_base            = "http://$HTTP_HOST";
   
   $dir_photo           = "$dir_base/photo";
   $url_photo           = "$url_base/photo";
   
   $dir_icon            = "$dir_base/icon";
   $url_icon            = "$url_base/icon";
   
   $dir_popup           = "$dir_base/popup";
   $url_popup           = "$url_base/popup";
   
   $dir_temp            = "$dir_base/temp";
   
   

   
   // PHP ERROR CONTROLL
   setCookie("warning", "");
   
   
   
   // Setting value for product brief info
   $cproduct_brief_info = "
   <table cellspacing='0' cellpadding='0' width='100%' border='0'>
      <tbody>
         <tr>
            <td align='center'><img height='61' alt='' src='/pictures/Image/lower_price.gif' width='64' border='0'/></td>
            <td width='10'>&nbsp;</td>
            <td valign='top'>
               <table cellspacing='1' cellpadding='1' border='0'>
                  <tbody>
                     <tr>
                        <td>
                           <table cellspacing='1' cellpadding='1' border='0' class='normal_12_black'>
                              <tbody>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                              </tbody>
                           </table>
                        </td>
                        <td width='5'>&nbsp;</td>
                        <td>
                           <table cellspacing='1' cellpadding='1' border='0' class='normal_12_black'>
                              <tbody>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                                 <tr>
                                    <td><img height='6' alt='' src='/pictures/Image/blue_square.gif' width='5' border='0'/>&nbsp;Text Here</td>
                                 </tr>
                              </tbody>
                           </table>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </td>
         </tr>
      </tbody>
   </table>
   ";
   
   
   // PHP TO READ DATABASE
   $db_connect = mysql_connect($db_host, $db_username, $db_password);
   mysql_select_db($db_name, $db_connect) || die(mysql_error());
   
   // read email user/orders templates
   $tsql_query                   = "SELECT * FROM setup_email WHERE email_id = 1";
   $result                    = mysql_query($tsql_query) or die (mysql_error());
   $row                       = mysql_fetch_array($result);
   $email_customer_order            = $row[email_text];
   
   
   // read email user/recover password templates
   $tsql_query                   = "SELECT * FROM setup_email WHERE email_id = 2";
   $result                    = mysql_query($tsql_query) or die (mysql_error());
   $row                       = mysql_fetch_array($result);
   $email_customer_recover_password = $row[email_text];
   
   mysql_close($db_connect);
   
   
   
   
   // FORM DATA POST CONTROLL
   reset ($HTTP_POST_VARS);
   while (list ($key, $val) = each ($HTTP_POST_VARS)) {
       $HTTP_POST_VARS[$key] = stripslashes ($HTTP_POST_VARS[$key]);
       $HTTP_POST_VARS[$key] = str_replace  ("'", "''", $HTTP_POST_VARS[$key]);
       $HTTP_POST_VARS[$key] = str_replace  ("\"", "\\\"", $HTTP_POST_VARS[$key]);
       $HTTP_POST_VARS[$key] = str_replace  ("\\", "", $HTTP_POST_VARS[$key]);
   }
   extract ($HTTP_POST_VARS, EXTR_OVERWRITE, "wddx");
   reset ($HTTP_POST_VARS);
   
   
   
   
   // CACHE CONTROLL
   header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header ("Cache-Control: no-cache, must-revalidate");
   header ("Pragma: no-cache");
   
   

?>

Open in new window

Change

mysql_select_db($db_name, $db_connect) || die(mysql_error());

to

mysql_select_db($db_name, $db_connect) or die(mysql_error());


'or' in PHP and a logical OR || are not the same
Avatar of wood1e

ASKER

I have change it.  Although there is no change. I presume you meant line 141 of code above?
OK - here is what I would change

Line 1: Use <?php instead of <? - most servers don't have SHORT_TAGS enabled

Line 29: Unless the MySQL database is hosted on another server elsewhere change this line to $db_host  = "localhost";

Line 66: $DOCUMENT_ROOT has not been defined. Stylistically is it considered bad form to use uppercase for user defined variables. Also you may actually mean $_SERVER['DOCUMENT_ROOT']   $dir_base = strip_tags( $_SERVER['DOCUMENT_ROOT'] );

Line 67: Similar to 66    $url_base  = strip_tags( "http://" . $_SERVER['HTTP_HOST'] );

Line 148: Should be   $email_customer_order  = $row['email_text'];

Line 155: Should be   $email_customer_recover_password = $row['email_text'];

This is obviously a very old script. $HTTP_POST_VARS was swicthed off years ago. Use $_POST instead



Try changing that lot and see how it works out




Avatar of wood1e

ASKER

Sorry I do not understand the answers to line

66
67 or do you mean just copy the line you have writen?

What is the document root? If it is not document root?  Upper or lower case.

Everthing is within a folder called anglo.

It is a very old script, trying to get it working for someone who is not wanting to pay a huge amoutn for an ecommerce site.  plus I wanted to learn on a old site i thought should be working!! :)
ASKER CERTIFIED SOLUTION
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wood1e

ASKER

That could be part of the reason the code is not working now?

As my servers were upgraded, and when thiking about it I noticed that an email came through saying something about php4/php5 that all websites in future should be coded php5 where possible!!

Ok I am not going to waste time on this, many thanks for your help.  The client will have to pay!! :)
Avatar of wood1e

ASKER

Many thanks