Link to home
Start Free TrialLog in
Avatar of usmansultan
usmansultanFlag for Australia

asked on

How do i link Web Pages with PHP?

We are in the process of migrating the website from our previous webhost to a new one, now i have transferred all the folders, and i have requested the webhost (i.e. netregistry) to provide us with a Temporary link until we redelgate our website to them, now on this website there is an SQL database which has around 8 tables, which i have created under the console-->php my admin, now when i uploaded all the files folders to the ftp, the website is working fine except where ever there is a PHP page it doesnt display it. The test link is http://rere6659.staging-zeus.netregistry.net/ , if you see under Announcements it says the database is down, how can i link it, or is there anything else needs to be done, Also under the Contact-->Make an enquiry it has a similar problem.
Any help would be much appreciated.
Avatar of Net_Worker
Net_Worker
Flag of Australia image

The database connector is most likely coded with a connection string to either your domain name or you old IP address. You need to edit the connection string to point to the new database.
Avatar of usmansultan

ASKER

Where i can find the database connector and how can i do that, would it be under the console of my new web host account.
I am under the PHP my Admin concole i have added a snapshot as well. Let me know if that helps.
PHP-My-Admin.JPG
Avatar of Vel Eous
Vel Eous

You should have a file somewhere that contains the PHP that is used to open a connection and select a database (or it may be done on the fly each time a connection is required).

This file is not part of phpMyAdmin.

Take a look at one of your files that require to connect to the database, check for something like:

mysql_connect
If you have not hard coded this page, I will first look on:

Check if there is any page included like
<?php
include './..............';
?>

Or,
<?php require_once("......"); ?>

If you find the file check the file and look on database connection defined like what Tchuki said above.

This is the normal practice otherwise you might have the db connection in the same page like index.php.

For Enquiry page check these lines in enquiry/index.php:

Notice: Undefined index: t in /clientdata/clients/r/e/response-systems.com/www/enquiry/index.php on line 2

Notice: Undefined index: p in /clientdata/clients/r/e/response-systems.com/www/enquiry/index.php on line 3

Hope this may help you.


I was not able to find any file which says mysql_connect, but on the main index page which is in php, i found a Php icon under Announcements, and on that icon the code is.

dbConnect("website");

$sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 2";
$result = mysql_query($sql);

$i=0;

      while ($i < 2) {
            $subject = mysql_result($result,$i,"subject");
            $subtitle = mysql_result($result,$i,"subtitle");
            $i++;

So do i have to change the name where its say dbconnect ("website"), if i have to change that what should i insert in  " ".
I have found one file with the name mysql.server, and the code of it is like this........

#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind

# MySQL daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 20
# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
 
# If you install MySQL on some other places than /usr/local/mysql-4.0.27, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

basedir=

# The following variables are only set for letting mysql.server find things.

# Set some defaults
datadir=/usr/local/mysql-4.0.27/var
pid_file=
if test -z "$basedir"
then
  basedir=/usr/local/mysql-4.0.27
  bindir=/usr/local/mysql-4.0.27/bin
else
  bindir="$basedir/bin"
fi

PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
export PATH

mode=$1    # start or stop

case `echo "testing\c"`,`echo -n testing` in
    *c*,-n*) echo_n=   echo_c=     ;;
    *c*,*)   echo_n=-n echo_c=     ;;
    *)       echo_n=   echo_c='\c' ;;
esac

parse_arguments() {
  for arg do
    case "$arg" in
      --basedir=*)  basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
    esac
  done
}

# Get arguments from the my.cnf file,
# groups [mysqld] [mysql_server] and [mysql.server]
if test -x ./bin/my_print_defaults
then
  print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
  print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
  print_defaults="$bindir/mysql_print_defaults"
else
  # Try to find basedir in /etc/my.cnf
  conf=/etc/my.cnf
  print_defaults=
  if test -r $conf
  then
    subpat='^[^=]*basedir[^=]*=\(.*\)$'
    dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
    for d in $dirs
    do
      d=`echo $d | sed -e 's/[       ]//g'`
      if test -x "$d/bin/my_print_defaults"
      then
        print_defaults="$d/bin/my_print_defaults"
        break
      fi
      if test -x "$d/bin/mysql_print_defaults"
      then
        print_defaults="$d/bin/mysql_print_defaults"
        break
      fi
    done
  fi

  # Hope it's in the PATH ... but I doubt it
  test -z "$print_defaults" && print_defaults="my_print_defaults"
fi

#
# Test if someone changed datadir;  In this case we should also read the
# default arguments from this directory
#

extra_args=""
if test "$datadir" != "/usr/local/mysql-4.0.27/var"
then
  extra_args="-e $datadir/my.cnf"
fi

parse_arguments `$print_defaults $extra_args mysqld mysql_server mysql.server`

#
# Set pid file if not given
#
if test -z "$pid_file"
then
  pid_file=$datadir/`/bin/hostname`.pid
else
  case "$pid_file" in
    /* ) ;;
    * )  pid_file="$datadir/$pid_file" ;;
  esac
fi

# Safeguard (relative paths, core dumps..)
cd $basedir

case "$mode" in
  'start')
    # Start daemon

    if test -x $bindir/mysqld_safe
    then
      # Give extra arguments to mysqld with the my.cnf file. This script may
      # be overwritten at next upgrade.
      $bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file >/dev/null 2>&1 &
      # Make lock for RedHat / SuSE
      if test -w /var/lock/subsys
      then
        touch /var/lock/subsys/mysql
      fi
    else
      echo "Can't execute $bindir/mysqld_safe from dir $basedir"
    fi
    ;;

  'stop')
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.
    if test -s "$pid_file"
    then
      mysqld_pid=`cat $pid_file`
      echo "Killing mysqld with pid $mysqld_pid"
      kill $mysqld_pid
      # mysqld should remove the pid_file when it exits, so wait for it.

      sleep 1
      while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
      do
      [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".$echo_c"
        flags=a$flags
        sleep 1
      done
      if [ -s $pid_file ]
         then echo " gave up waiting!"
      elif [ -n "$flags" ]
         then echo " done"
      fi
      # delete lock for RedHat / SuSE
      if test -f /var/lock/subsys/mysql
      then
        rm -f /var/lock/subsys/mysql
      fi
    else
      echo "No mysqld pid file found. Looked for $pid_file."
    fi
    ;;

  'restart')
    # Stop the service and regardless of whether it was
    # running or not, start it again.
    $0 stop
    $0 start
            ;;

  *)
    # usage
    echo "Usage: $0 start|stop|restart"
    exit 1
    ;;
esac
To give you guys more info, on the old webhost all the files were located under\www\htdocs\. but on the new webhost it was not reading the index.php file from htdocs, so i have copied all the files across to the main ftp folder, the rest of the website is working ok.its just the php stuff, thats not coming up as its suppose to......
Then perhaps php is not enable on the new host. In the htdocs directory create a new file called phptest.php. In that file type the following;

<? phpinfo() ?>

Open a web broswer and type the full path example: http://mydomain.com/phptest.php

If php is enabled you will see a page generated with the php information. If the page show the text above then php is not enabled.
Thanks for your reply....
PHP is enabled on the webhost, i have checked it under console, and as i have mentioned i have copied all the files across from htdocs to the main ftp directory that means there is no subdirectory.
The only thing that was disabled was CGI. Which i have enabled........
Ok one thing started working after enabling CGI, the enquiry page.......
Now the main index page is left...........on which the anouncement database is showing its down....
and the support centre as well...which is not working...
So should i still create the webpage as "Net worker" suggested and try out if php is running or not...
The ftp directory should be the same physical location as your web root directory. So what you have done has no real effect and makes no actual change. If your web server is configured to use htdocs as the document root then your web cannot run. You mentioned that .html is working but .php is not and therefore it is reasonable to assume that php is not functioning on your server. The test that I have suggested will determine if this is the case.

If php is in fact working then you will need to find where the variable website is defined from the statement dbConnect("website"); This is usually defined in a file in your includes directory. look for a file called dbConnect.inc or dbConnect.php. In fact the extension is arbitrary and you can usually find a reference to in your index file.

I don't really understand what you mean when you said you found an icon with the dbConnect code but that code is the reference to your database and creates the connections. It uses the dbConnect("website"); variable and that is most likely causing your issue (on the basis that php is in fact working).
I will make the information more clear, on dbConnect issue the database is called "website", and i believe this function has been defined twice in the website.

1)/admin/db.php
2)/support/centre/db.php

The code is:

<?php // db.php

$dbhost = 'response-systems.com';
$dbuser = 'root';
$dbpass = 'queensarms';

function dbConnect($db='') {
      global $dbhost, $dbuser, $dbpass;
      
      $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
            or die('The site database appears to be down.');
            
      if ($db!='' and !@mysql_select_db($db))
            die('The site database is unavailable.');
            
      return $dbcnx;
}

?>

So what would be the best approach, to rename the DB or change the code, if the option is renaming the DB where do i have to go and rename the DB.

Thanks.
The problem is with DB connection according to your code in db.php

 $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
            or die('The site database appears to be down.');

Check if your DB host, DB user name and DB password is correct.

Error message is fetched from here die('The site database appears to be down.');
SOLUTION
Avatar of mekh
mekh
Flag of Hong Kong 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
I am still think your php is suspect as you have stated that no php pages appear correctly.  What mekh has said is correct but this will only work with a functioning php. What I have suggested earlier is the quickest way to establish where your problem lies. If phpinfo() yeilds no results then you have to fix php. If it does only then should you start to mess with usernames and passwords.

Assuming that php is functioning you will need to change $dbhost = 'response-systems.com'; to suit the hostname of the server. From your earlier post you would probably need to have http://rere6659.staging-zeus.netregistry.net but phpmyadmin should clearly show you the correct hostname to be using.
The hostname should not include http://
It had helped me, i have changed the DB Host name, User and Password, but still its not connecting....
oh I didn't notice .com in dbhost.

That could be the reason.

I can see php running in some pages like http://www.response-systems.com/enquiry/index.php

and there is also perl running in the page http://www.response-systems.com/cgi-bin/knowledgebase/search.pl?Terms=articles

I assume php is functioning.
Thanks for your replies,
Net Worker i will definetly try your suggestion and will let you know.....because even after changing the user and db details doesnt help.......
Mekh, i have enabled PHP on the console, but as networker said i should test it.
The link http://www.response-systems.com/enquiry/index.php is for the active website that is running, i am migrating it to a different webhost, and the link that they provided is http://rere6659.staging-zeus.netregistry.net/, on which i am testing the website, and over here the php connections are not working.
I've taken a closer look at your site and it appears that PHP is running. I say this because your support login gives a php error. I would still do the test for sanity sake but this looks to be a database authentication issue. It also looks as though your .htaccess files may be missing or may need to be updated for the new site.
whats the purpose of .htaccess, and where i can locate it.
I have tested the PHP its working, i have upload to the file in the main directory, that means it was not working when i uploaded it under /www/htdocs, but when i uploaded it under the root folder it started working, i have uploaded all of my files and folders under the root folder, it seems like the problem is somewhere else.........

PHPTest.JPG
I am pasting the DB Connect Information.
$host = "MYSQL-3.my-domain.com";
    $dbname = "rs_my_domain_com";
    $username = "username";
    $password = "password";
   
    $connection = mysql_connect($host, $username, $password);
    mysql_select_db($dbname,$connection);
   
    /*
    Check to see if connection was successful
    */
    ?>

So on the website under dbconnect variable which one should be the right one, MYSQL or rs.
Can you try this simple code that will connect to your database in a single php file rather than calling function.

Just a try:


<?php //test_db_connect.php

$hostname = "hostname"; //Change accordingly
$username = "db_user_name"; //Change accordingly
$password = "db_user_password"; //Change accordingly

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
echo "Connected to MySQL";

//select a database to work with
$select_db = mysql_select_db("website",$dbhandle) //I changed to website (your db)
  or die("Could not select website");

//If connected, execute some SQL query

//close the connection
mysql_close($dbhandle);
?>
oh same time:

So mekh should i try the code that you asked me to do,
but where should i include this code and how can i call it or test it.
it should be rs because according to your code:

$host = "MYSQL-3.my-domain.com";
$dbname = "rs_my_domain_com";

MYSQL-3.my-domain.com ==> This is Database host

(I never come up with .com in the db host is the host correct)

rs_my_domain_com           ==> This is your database
SOLUTION
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
Yes the host name is correct i pasted it from the Console, can you please tell me what Networker meant by "database authentication issue" in is last post.....
What i meant was exactly what we are working through now. Run the code that mekh has given you so that you can  test authentication to the database.

I still think you are using the wrong hostname and database details in your connection string. From the image you posted you should be using the following;

host:MYSQL-3.servers.netregistry.com
database:rs_response_systems_com

Check that you have the correct user permissions in phpmyadmin for the database user you are using. You will need a user who has access to that database @localhost and/or @MYSQL-3.servers.netregistry.com
I have tested the code as you said, and it generated this error.

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'MYSQL-3.response-systems.com' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'MYSQL-3.response-systems.com' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL

This error message clearly says that host name is NOT CORRECT.
I will check the user permissions pn phpmyadmin, just wanted to make one thing clear,
from console of the webhost its showing the host is
$host = "MYSQL-3.response-systems.com";
but as Net Worker suggested it should be
host:MYSQL-3.servers.netregistry.com
So which one should i use.........
You originally said this was a staging area till your transfer was complete. Once the DNS is transfered then you can use MYSQL-3.response-systems.com but until then you have no DNS to resolve that host so you will need to use MYSQL-3.servers.netregistry.com
where is your database?

Response-systems.com or servers.netregistry.com?

Mekh response-systems.com is his domain and he has transferred to netregistry for his hosting. His DNS is not transferred which is causing his issues.
My database is at Netregistry, so i will change my host name on all the files where its mentioned, but if i am not wrong i dont have to change the dbname.
Just change it on the test code that mekh gave you first. Don't mess with the web site till you actually know where the problem lies. Once the test code gives you success then make the appropriate changes.
Yeah thats the good practice.

Try the test code first and if it works... you can go for other changes.
I have change the code, i have just pasted it to make sure i am not doing anything wrong

<?php //test_db_connect.php

$hostname = "MYSQL-3.servers.netregistry.com"; //Change accordingly
$username = "username"; //Change accordingly
$password = "password"; //Change accordingly

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
echo "Connected to MySQL";

//select a database to work with
$select_db = mysql_select_db("rs_response_systems_com",$dbhandle) //I changed to website (your db)
  or die("Could not select website");

//If connected, execute some SQL query

//close the connection
mysql_close($dbhandle);
?>


but, Its still giving the same error

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'MYSQL-3.servers.netregistry.com' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL
Try using localhost as the hostname.
Code is fine.

The problem is with the host name.

Is this MYSQL-3.servers.netregistry.com the right host name?

From netregistry.com support page: http://www.netregistry.com.au/customer-service/support/database/mysql_code.php

<?
$host = "mysql.yourdomainname";
$dbname = "dbname_domain_com";
$username = "dbusername";
$password = "dbpassword";
$connection = mysql_connect($host, $username, $password);
mysql_select_db($dbname,$connection);
/*
Check to see if connection was successful
*/
?>
Doesnt want to connect same error.

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL


Would it be helpful to anyone of you, if i will send you the username and password and u can check it out from your end.......
try this in your dbhost

mysql.response-systems.com

same error if itry mysql.response-systems.com.

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mysql.response-systems.com' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL
As I said earlier you will need a DNS record pointing to that hostname or it will fail.
I am pasting the Database information again,from the console of the webhost, hope it might help u guys........

<?
    $host = "MYSQL-3.response-systems.com";
    $dbname = "rs_response_systems_com";
    $username = "username";
    $password = "password";
   
    $connection = mysql_connect($host, $username, $password);
    mysql_select_db($dbname,$connection);
   
    /*
    Check to see if connection was successful
    */
    ?>
try without .com

mysql.response-systems
As i said before that i am happy to provide the username and password to any one of you, through email.....if it will be helpful.......
also take out the MYSQL-3 portion.
Networker which dns record should i redirect to this host.....because i cant redirect the original one until this is working........
and mekh i tried without.com, it generates the same error..

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mysql.response-systems' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL
and with that portion removed put the .com back in.
SOLUTION
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
so networker you are suggesting that the host should be "response-systems" or "mysql.response-systems"
i have tried 'MYSQL.servers.netregistry.com' , doesnt work.......
According to netregistry it should be mysql.response-systems.com. The issue you have is that you are running from a staging host and its apparent that DNS is not yet working. The actual database host is MYSQL-3.servers.netregistry.com which can be seen in your phpmyadmin console. The problem you face is that netregistry will have controls in place to force you to use mysql.response-systems.com but until your website is cut over correctly you will need some extra configuration to make it work.

Several options are setup a DNS host record as mentioned above. Ask netregistry to add an entry in the hosts file of the server and have it do local lookups or allow your account to connect to the database by IP address and provide you with that address.
You haven't yet tried mysql.response-systems.com have you?
ok will do now.....
I have tried 'mysql.response-systems.com'  it doesnt work,..
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mysql.response-systems.com' (1) in /clientdata/clients/r/e/response-systems.com/www/dbtesting.php on line 9
Unable to connect to MySQL
Did you enable mysql?

http://www.netregistry.com.au/customer-service/support/database/mysql.php

Have you asked any support question to them?

There might be some configuration needed in netregistry server.

my guess.
ok guys i have called up netregistry and they have given me this host address.
mysql-3.netregistry.net.
and it worked.
You can check it........
Nice to know that finally it is sorted...

Thats where we were digging till now...

But right now its giving errors on Announcement page.....
where would i have to go and change it......
and support centre page as well....
what is on line 123 and 124 in index.php
115        dbConnect("rs_response_systems_com");

117               $sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 2";
118                            $result = mysql_query($sql);

120                                        $i=0;


122      while ($i < 2) {
123            $subject = mysql_result($result,$i,"subject");
124            $subtitle = mysql_result($result,$i,"subtitle");
125            $i++;
Can you show me the whole function?
Do you have data in the table? Your tables look to be empty.
Sure, i am pasting the codes for the whole index file, let me know if u need it with line numbers:

<?php

include_once 'admin/db.php';
include_once 'admin/common.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Site Copyright 2006 Response Systems -->

<head>
      <meta name="author" content="Hadley Grindrod" />
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
      <link rel="stylesheet" href="style.css" type="text/css" />
      <title>Response Systems :: Home</title>
</head>

<!-- Begin Site Body -->

<body>
      <div class="content">
      
      <!-- Begin Header Section -->
      
            <div class="header_top"></div>
            <div class="header">
            
            <!-- Begin Navigation Bar -->
            
                  <div class="header_right">
                        <div id="nav">
  <p><a href="solutions/">Solutions</a> | <a href="support/">Support</a> | <a href="links/">Links</a> | <a href="contact/">Contact</a></p>
                        </div>
                        <div class="header_search">
<form method="get" action="http://response-systems.com/cgi-bin/search/search.pl">

<p><input type="text" name="Terms" class="search" /> <input type="submit" value="Search" class="submit" /></p>
                              </form>
                        </div>
                  </div>
                  
            <!-- Begin Logo Placement -->
                  
                  <div class="header_left">

<a href="#"><img src="images/responselogo.jpg" alt="Response Systems" /></a>
                  </div>
            
      <!-- Finish Header Section -->      
                        
            </div>
            
            <div class="header_bottom"></div>
            
      <!-- Begin Banner Placement -->
            
            <div class="spacer"></div>
            <div class="header_top"></div>
            <div class="subheader">

<a href="solutions/"><img src="images/banner.jpg" alt="Solutions" /></a>
            </div>
            <div class="header_bottom"></div>
            <div class="spacer"></div>
            
      <!-- Begin Content Area -->
            
            <div class="header_top"></div>
            
            <!-- Column 1 : Left : Solutions -->
            
            <div class="column">
                  <div class="box_top">

            <h2><a href="solutions/">Solutions:</a></h2>
                  </div>      
                  <div class="box_icon">      

<a href="solutions/cse/"><img src="images/icons/cseicon.gif" alt="CSE-Edit/Access" /></a>

<h2><a href="solutions/cse/">CSE-Edit/Access</a></h2>

<p><a href="solutions/cse/">AllFusion Gen Client Server Encyclopedia Solutions</a></p>
                  </div>
                  <div class="box_icon">
<a href="solutions/ce/"><img src="images/icons/ceicon.gif" alt="CE-Edit/Access" /></a>
<h2><a href="solutions/ce/">CE-Edit/Access</a></h2>
<p><a href="solutions/ce/">AllFusion Gen Host Encyclopedia Solutions</a></p>
                  </div>
                  <div class="box_bottom"></div>
            </div>
            
            <!-- Column 2 : Centre : Support -->
            
            <div class="column">
                  <div class="box_top">
                        <h2><a href="support/">Support:</a></h2>
                  </div>      
                  <div class="box_icon">
<a href="http://www.response-systems.com/cgi-bin/knowledgebase/search.pl?Terms=articles"><img src="images/icons/base.gif" width="50" alt="Knowledgebase" /></a>
<h2><a href="http://www.response-systems.com/cgi-bin/knowledgebase/search.pl?Terms=articles">Knowledgebase</a></h2>
<p><a href="http://www.response-systems.com/cgi-bin/knowledgebase/search.pl?Terms=articles">For quick answers to the most common problems</a></p>
                  </div>
                  <div class="box_icon">
<a href="support/centre/"><img src="images/icons/centre.gif" width="50" alt="Support Centre" /></a>
<h2><a href="support/centre/">Support Centre</a></h2>
<p><a href="support/centre/">Log in for access to technical support</a></p>
                  </div>
                  <div class="box_bottom"></div>      
            </div>      
            
            <!-- Column 3 : Right : Announcements -->
            
            <div class="column">
                  <div class="box_top">
                        <h2><a href="announcements/">Announcements:</a></h2>
                  </div>      
                  <?php

dbConnect("rs_response_systems_com");

$sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 2";
$result = mysql_query($sql);

$i=0;

      while ($i < 2) {
            $subject = mysql_result($result,$i,"subject");
            $subtitle = mysql_result($result,$i,"subtitle");
            $i++;

?>                  
                  <div class="box_icon">      
<a href="announcements/index.php#news_item<? echo $i ;?>"><img src="images/icons/news<? echo $i ;?>.gif" width="50" alt="<? echo $subject; ?>" /></a>
<h2><a href="announcements/index.php#news_item<? echo $i ;?>"><? echo $subject; ?></a></h2>
<p><a href="announcements/index.php#news_item<? echo $i ;?>"><? echo $subtitle; ?></a></p>
                  </div>
                  
<?

      }

?>
                  <div class="box_bottom"></div>
            </div>
            
      <!-- Finish Content Area -->
            
            <div class="header_bottom"></div>
            
      <!-- Begin Footer -->
            
            <div class="language">
<a href="fr/"><img src="images/Language/France.png" alt="French" /></a>
<a href="de/"><img src="images/Language/Germany.png" alt="German" /></a>
<a href="es/"><img src="images/Language/Spain.png" alt="Spanish" /></a>
            </div>
            <div class="footer">
<p><a href="about/">About Response Systems</a> | <a href="privacy/">Privacy</a> | <a href="enquiry/">Feedback</a> | <a href="contact/">Contact</a><br />
                  &copy; Copyright 2006 Response Systems</p>
            </div>
      </div>
</body>
</html>
SOLUTION
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
these are the tables...

Admin

+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| user  | varchar(10) | YES  |     | NULL    |       |
| pass  | varchar(12) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.04 sec)

Announcements

+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | int(11)     |      | PRI | NULL    | auto_increment |
| subject  | varchar(20) | YES  |     | NULL    |                |
| subtitle | varchar(80) | YES  |     | NULL    |                |
| content  | text        | YES  |     | NULL    |                |
| date     | date        | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

Downloads

+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| ptf         | int(11)     | YES  |     | NULL    |       |
| product     | char(3)     | YES  |     | NULL    |       |
| version     | varchar(32) | YES  |     | NULL    |       |
| name        | varchar(32) | YES  |     | NULL    |       |
| description | text        | YES  |     | NULL    |       |
| issue       | int(11)     | YES  |     | NULL    |       |
| file        | varchar(24) | YES  |     | NULL    |       |
| odbcfile    | varchar(24) | YES  |     | NULL    |       |
| ora9file    | varchar(24) | YES  |     | NULL    |       |
| ora10file   | varchar(24) | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
10 rows in set (0.01 sec)

Known Issues

+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int(11)     |      | PRI | NULL    | auto_increment |
| product | char(3)     | YES  |     | NULL    |                |
| version | varchar(5)  | YES  |     | NULL    |                |
| subject | varchar(64) | YES  |     | NULL    |                |
| content | text        | YES  |     | NULL    |                |
| date    | date        | YES  |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

Support Number

+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| ce    | int(11) | YES  |     | NULL    |       |
| cse   | int(11) | YES  |     | NULL    |       |
| other | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)

Users

+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| user    | varchar(6)  | YES  |     | NULL    |       |
| pass    | varchar(12) | YES  |     | NULL    |       |
| mail    | varchar(32) | YES  |     | NULL    |       |
| name    | varchar(32) | YES  |     | NULL    |       |
| phone   | varchar(16) | YES  |     | NULL    |       |
| company | varchar(32) | YES  |     | NULL    |       |
| last    | date        | YES  |     | NULL    |       |
| count   | int(11)     | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
8 rows in set (0.00 sec)
and when i imported them under phpmyadmin, thats how they look like.

An example of Announcement table....


Announcements-table.JPG
Yes but is there any data in those tables?
See space usage? 0 Bytes.
when i was migrating the website, i was given the tables that i pasted....
So there should be data in the tables..
what kind of...
I suspect in the code:

Disable
//   $subject = mysql_result($result,$i,"subject");
//   $subtitle = mysql_result($result,$i,"subtitle");
 

in your below code and see if the result.

   dbConnect("rs_response_systems_com");

117               $sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 2";
118                            $result = mysql_query($sql);

120                                        $i=0;


122      while ($i < 2) {
123            $subject = mysql_result($result,$i,"subject");
124            $subtitle = mysql_result($result,$i,"subtitle");
125            $i++;
Or better go step by step:

first only try to connect database only if that works start query if that works start fetching.

This way you can find out where ur problem is.
Tables and data export separately. You have no data as shown by the phpmyadmin image.
Because you are using different Mysql server now so there might be some migration issues between two server.

Are those mysql server same version?

some query does not work if the mysql version is different.
i am bit confused here, because networker said the code is write and there is no data in the tables.....and you are suggesting to change the code....so what should i do first....
Get some data into the database and the index page issue will disappear.
As a test run this query in phpmyadmin

SELECT * from Announcments;

You will soon see if you have any data or not.
networker what kind of data there should be in tables...
i have run the query and it didnt return any result.
SQL-Query.JPG
The data that shows up on the page. Subject, Subtitle, Content, Date, ID
SO there you go. No data.
Net Worker good start.

now usmansultan you need to insert the data in that table.

Well from you've said you only recieved the tables. You need to get an export of all the data and then import all data for all the tables.
Thanks guys....
but what kind of data should i insert in these tables......
the data from the old database would be a good start ;)
Did you mean by exporting all the fields from the table, and then importing them back again,
look up at the snap shot, you might get a better idea.
Export-Tables.JPG
I appreciate how early you are responding to my questions..
Thanks a ton.....
Your old database has this in it (exluding the ID because I don't know hats actual ID is)

ID;1
Subject; New Software Release
Subtitle; CSE-Access V7.6
Content; CSE-Edit/Access Version 7.6 is now commercially available with the following enhancements:

· Packaging Report. The Packaging Report has been revamped to detail the full packaged contents of a load module. This includes the dynamic link flag and member name value for all listed objects. The report is also now available from the Pick List so that the packaging details of multiple Load Modules/Procedure Steps can be returned in one operation.

· View Size Calculator. The View Size Calculator has been updated in line with the changes made to the Gen R7.6 Generation Consistency Checker. View Sizes are now calculated for both COBOL and C.

· Custom SQL. The ability to execute your own custom written SQL against multiple encyclopedia objects simultaneously is now available from the CSE-Access Pick List.
You need to run that process in the image on the old database and save it to a file. You then run an import process on the new database.
Sorry that wasn't clear. Run the export you have shown on the old database. Copy the output into a file. Then run the import from the data in the file onto the new server.
Ok will do.... the old webhost is on https://www.verio.com/,
I have to get the username and password to log in.

Before that let me get it right....

i have to export the tables and import them back in to the new webhost.
but how would i import into the new database...there is no option for importing, there is an option for insert for which i am pasting the snapshot.
Insert.JPG
No you don't need to export the tables you need to export the data. Once you export to an SQL file it should include all the insert statements. You simply paste that into phpmyadmin as an SQL query and let it insert all the data.
Ok will do...i have contacted the people for verio webhost to send me user name and password to access the console, and regarding your post at 04:24PM , all of those reports, and sql quries would be there.
Thats correct. Whatever data is currently in the old database, once imported into the new one will show up as you expect it to.
sorry for late reply, but i was waiting for them to send the username and password details, now i have the username and password, but they use telnet to access MYSQL database, so how can i export the data from telnet....
Just one more quick question, in PHPMYadmin, when i click on the database name, it doesnt show any option to import/insert the database, but when i click on any table it give me an option to insert the fields, but the fields i believe are already there.......so what i am missing.....what i have to do....
Firstly i know i have to import the database from the old webhost in which i need help because that have to be done through telnet...  
I have not use Telnet but this article may be useful for you.

Have a look:

http://www.jtpratt.com/how-to-export-and-import-very-large-mysql-databases/

More relevant:

http://www.hostingmanual.net/other/mysql.shtml

For more result

Go to Google my best friend :-)
ASKER CERTIFIED SOLUTION
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
sure will try now.Thanks for your replies.....
Bit strange when i enterred to the root directory of mysql, i enterred the name for the database,
which is "use website", and then after that i typed the name of the database and hit enter, it said database changed.
After that i issued the command "mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]" the cursos changed from ">" to "->" and nothing happend i guess, what should i do now.....
If you entered the db name in connection then its already using it. Check that the output file has been created.

you should be typing at the linux prompt:

mysqldump -u adminame -p password website > backup.sql

You should then be sent back to your linux prompt. Then check for the file called backup.sql.
what should i write to check where backup.sql is located.....
and how can i import it.....
should i issue this command...
mysql -uusername -ppassword dbname < backup.sql
but i think i dont have to specify the dbname, because as you said i am already there.
and is this command can be also used to restore the database, because i dont want to mess anything up, this is live website, not the test one.....
No you should not be using mysql. Issue the command I showed you already. You need to use mysqldump.

Once the dump is complete type ls and look for your file. If you can't find the file issue the following command;
find / -name backup.sql

You then need to ftp or scp this sile across to the new server. Then follow the instructions I gave you to import into phpmyadmin.
I am getting this error when iam using the sqldump comand that you gave me..

/usr/local/mysql/bin/mysqldump: Got error: 1049: Unknown database 'password' when selecting the database

So it means its not able to find the database, i have tried different combination with the database name, but everytime same error......
No it means that you forgot the -p switch and have entered the word password instead of the database name. Look, if the database is website the user is root and the password is letmein the command would be;

mysqldump -u root -p letmein website > backup.sql

Try again with the proper switches and use the command from my first example. You need to use your own login infor you can't just copy what I write here it has to be the proper user for the database.
I am enterring the code in right parameters, i am not copying and pasting.
I am enterring the command.
response-systems% mysqldump -u root -p qms website > backupfile.sql
when i enter that it ask me for the password, and when i enter the password that i have mentioned it produces the error that i have posted.......

Now i can enter this command
mysql h response-systems.com u root p
enter the password and then it goes under
my sql>
I have tried enterring the sqldump comand in both areas, it gives error at response-systems % but when i enter the same command on mysql> it doesnt say anything...and ls command doesnt work under mysql as well...
OK your version is not allowing the password to be appended to the string. In that case your command will be;

response-systems% mysqldump -u root -p website > backupfile.sql

then enter the password when requested to.
Thanks..That file "backupfile.sql"is created.
I used the ls command and now i can see it, so how can i export it.......
which command can i use, to export it........
I downloaded the file through ftp...so how can i import that to the new website......
Should i delete all the tables that are in phpmy admin and import this backup file.....
I am assuming that means the file is on the new server. Follow the instruction from my earlier post at 02:46PM EST.
will do...should i delete all the tables....so that when i import this file it will create everthing....all the tables...i am thinking if i import this it might conflict/import wrong fields into different tables....thats why i was wondering should i do it or not.....
Take a look at the file. You will see that it will have a statement to drop the database and it will the then rebuild the database, create the tables, and insert the data.

I am working on the basis that your database structure is unchanged and if that is the case you can chose to either leave the drop statement in there or you can remove it which will then just import the data.

If you chose to remove the drop statement and import the data only search the file for 'create table' entries to find which tables the file wants to create and delete them also.
Just to clarify if you only want to insert the data, make sure the file only has statements which begin with INSERT INTO and no statements that begin with DROP or CREATE
It has started working, but if click on Announcements page, its giving an error, on the left side,
"Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /clientdata/clients/r/e/response-systems.com/www/announcements/index.php on line 75

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /clientdata/clients/r/e/response-systems.com/www/announcements/index.php on line 76


and on the bottom of the page its giving an error.
"Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /clientdata/clients/r/e/response-systems.com/www/announcements/index.php on line 104

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 4 in /clientdata/clients/r/e/response-systems.com/www/announcements/index.php on line 105


Should i paste those lines over here.......
68   dbConnect("rs_response_systems_com");

70     $sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 3";
71     $result = mysql_query($sql);

73       $i=0;
74      while ($i < 3) {
75      $subject = mysql_result($result,$i,"subject");
76            $subtitle = mysql_result($result,$i,"subtitle");
77            $i++;
78            if ($subject != "") {
79                    ?>                  
101      $i=0;

103      while ($i < 3) {
104            $subject = mysql_result($result,$i,"subject");
105            $content = mysql_result($result,$i,"content");
106            $i++;
If you want to see the whole function.....


<?php
 
include_once '../admin/db.php';
include_once '../admin/common.php';
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
<!-- Site Copyright 2006 Response Systems -->
 
<head>
	<meta name="author" content="Hadley Grindrod" />
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
<link rel="stylesheet" href="../style.css" type="text/css" />
<title>Response Systems :: Announcements</title>
</head>
 
<!-- Begin Site Body -->
 
<body>
	<div class="content">
	
	<!-- Begin Header Section -->
	
		<div class="header_top"></div>
		<div class="header">
		
		<!-- Begin Navigation Bar -->
		
			<div class="header_right">
				<div id="nav">
    				<p><a href="../solutions/">Solutions</a> | <a href="../support/">Support</a> | <a href="../links/">Links</a> | <a href="../contact/">Contact</a></p>
				</div>
	<div class="header_search">
<form method="get" action="http://response-systems.com/cgi-bin/search/search.pl">
			<p><input type="text" name="Terms" class="search" /> <input type="submit" value="Search" class="submit" /></p>
					</form>
				</div>
			</div>
			
		<!-- Begin Logo Placement -->
			
			<div class="header_left">
				<a href="../"><img src="../images/responselogo.jpg" alt="Home" /></a>
			</div>
		
	<!-- Finish Header Section -->	
				
		</div>
		
		<div class="header_bottom"></div>
		<div class="spacer"></div>
		
	<!-- Begin Content Area -->
		
		<div class="header_top"></div>
		
		<!-- Column 1 : Left : News Links -->
		
		<div class="column">
			<div class="box_top">
				<h2>Announcements</h2>
			</div>	
<?php
 
dbConnect("rs_response_systems_com");
 
$sql = "SELECT * FROM announcements ORDER BY id DESC LIMIT 3";
$result = mysql_query($sql);
 
$i=0;
	while ($i < 3) {
		$subject = mysql_result($result,$i,"subject");
		$subtitle = mysql_result($result,$i,"subtitle");
		$i++;
		if ($subject != "") {
?>			
			<div class="box_icon">	
				<a href="index.php#news_item<? echo $i ;?>"><img src="../images/icons/news<? echo $i ;?>.gif" width="50" alt="<? echo $subject; ?>" /></a>
				<h2><a href="index.php#news_item<? echo $i ;?>"><? echo $subject; ?></a></h2>
				<p><a href="index.php#news_item<? echo $i ;?>"><? echo $subtitle; ?></a></p>
			</div>
			
<?
		}
	}
 
?>
			<div class="box_bottom"></div>
		</div>
		
		<!-- Column 2 : Right : Content -->
		
		<div class="column2">
			<h2>Announcements</h2>
 
<?
			
	$i=0;
 
	while ($i < 3) {
		$subject = mysql_result($result,$i,"subject");
		$content = mysql_result($result,$i,"content");
		$i++;
		
?>
			<!-- News Item <? echo $i ;?> -->
			
			<p id="news_item<? echo $i ;?>"><b><? echo $subject; ?></b></p>
			<p><? echo nl2br($content); ?></p>
			
<?
 
	}
 
?>
		
		</div>
 
	<!-- Finish Content Area -->
		
		<div class="header_bottom"></div>
		
	<!-- Begin Footer -->
		
		<div class="language">
			<a href="../fr/"><img src="../images/Language/France.png" alt="French" /></a>
			<a href="../de/"><img src="../images/Language/Germany.png" alt="German" /></a>
			<a href="../es/"><img src="../images/Language/Spain.png" alt="Spanish" /></a>
		</div>
		<div class="footer">
			<p><a href="../about/">About Response Systems</a> | <a href="../privacy/">Privacy</a> | <a href="../enquiry/">Feedback</a> | <a href="../contact/">Contact</a><br />
			&copy; Copyright 2006 Response Systems</p>
		</div>
	</div>
</body>
</html>

Open in new window

Should i use "mysql_fetch_assoc "  instead of  "$subject = mysql_result($result,$i,"subject")
This looks to me as though its trying to get to i=4 but the function is supposed to stop at i=2.

Given that we have now resolved your original question and you are now able to connect to your database, you should close this thread and open a new question in the PHP zone. You will likely get a PHP guru give you an answer within minutes.
ok...will do....can you please tell me how should i start a new question, means how much details will be needed over in the new question, or would you be able to help me in the new question as well.......
In your new question, take everything from your last 3 posts, the 2 with errors and the code.  The question just needs to ask for help on the specific issue:

website and database has been moved to a new server. No changes were made to the code but I am now getting this error.
Thanks a lot Networker and Mekh, you have given great in diagnosing the issue and pointing me to right direction.
Hi Networker, i have posted the question but havent received any reply in the last 2 hours...Can you have a look at it please.....Its posted under PHP zone, and the link is
https://www.experts-exchange.com/questions/23478184/PHP-and-MySQL-errors-during-Website-Transition.html
Thanks.
Nice to know that part of your problem is sorted