Solved

website not working, connecting to database

Posted on 2011-03-02
11
826 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:wood1e
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35016380
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() );

0
 

Author Comment

by:wood1e
ID: 35016462
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.
0
 
LVL 17

Expert Comment

by:psimation
ID: 35016472
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.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:wood1e
ID: 35017308
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

0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35017449
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
0
 

Author Comment

by:wood1e
ID: 35017803
I have change it.  Although there is no change. I presume you meant line 141 of code above?
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35018032
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




0
 

Author Comment

by:wood1e
ID: 35018229
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!! :)
0
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 35018475
Lines 66 and 67 should be

$dir_base = strip_tags( $_SERVER['DOCUMENT_ROOT'] );
$url_base = strip_tags( "http://" . $_SERVER['HTTP_HOST'] );


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

The document root directory under which the current script is executing, as defined in the server's configuration file. See http://www.php.net/manual/en/reserved.variables.server.php (scroll down for more info)


"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!! :)"

This script is from PHP3 or possibly the early PHP4 era (HTTP_POST_VARS was deprecated in 2001 in PHP4.1) so that makes it more than 10 years old. Most of the features of those early versions were riddled with bad practices and security holes which is why they were changed or turned off or removed completely. Learning PHP on code this old is a waste of your time because no modern version of PHP will execute those scripts without alteration.

Your customer will find that on his next server upgrade, all this old code will simply stop working unless you go through it all and bring it up to date first.
0
 

Author Comment

by:wood1e
ID: 35018734
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!! :)
0
 

Author Closing Comment

by:wood1e
ID: 35018774
Many thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Finding Duplicates in a Normalized Database 6 28
Make check boxes work 8 46
Change a button after e-mail 4 21
MySQL programmer starter 25 29
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question