Jump to content

PHP Live MySQL server Connectivity Issue


kshyju

Recommended Posts

Dear techies,

Please help me to solve this issue

 

I have a PHP site where i am having a mysql db connectivity.while developing i used the following code to connect to the DB and i included this page in all my PHP pages.

In my local environment.it was working pretty fine.but when it comes to the deployment stage(in www) It is not working

 

CODe

-----------

<?php

 

$link = mysql_connect('mysql400.ixwebhosting.com', 'my_user', 'my_password);

if (!$link) {

    die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

mysql_select_db('my_database');

echo '<br>DB Selected successfully';

$res=mysql_query('select * from students');

$cnt=mysql_num_rows($res);

echo "<br> COUNT : ".$cnt;

 

?>

 

 

For the above code i am getting an o/p as the following

-----------------------------------------------------------------------

Connected successfully

DB Selected successfully

COUNT :

 

 

This is the first time i am trying with a live db server. (I am a newbie in PHP)

I am able to access the phpMyAdmin from my browser.

(http://mysql400.ixwebhosting.com/).

when i enter the user name and password,

i can see the DB , tables and all

 

 

Please help me to resolve this

 

Dear techies,

Please help me to solve this issue

 

I have a PHP site where i am having a mysql db connectivity.while developing i used the following code to connect to the DB and i included this page in all my PHP pages.

In my local environment.it was working pretty fine.but when it comes to the deployment stage(in www) It is not working

 

CODe

-----------

<?php

 

$link = mysql_connect('mysql400.ixwebhosting.com', 'my_user', 'my_password);

if (!$link) {

    die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

mysql_select_db('my_database');

echo '<br>DB Selected successfully';

$res=mysql_query('select * from students');

$cnt=mysql_num_rows($res);

echo "<br> COUNT : ".$cnt;

 

?>

 

 

For the above code i am getting an o/p as the following

-----------------------------------------------------------------------

Connected successfully

DB Selected successfully

COUNT :

 

 

This is the first time i am trying with a live db server. (I am a newbie in PHP)

I am able to access the phpMyAdmin from my browser.

(http://mysql400.ixwebhosting.com/).

when i enter the user name and password,

i can see the DB , tables and all

 

 

Please help me to resolve this

 

use bellow


$link = mysql_connect('mysql400.ixwebhosting.com', 'my_user', 'my_password);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db('my_database') or die('couldn't select db'.mysql_error);
echo '<br>DB Selected successfully';
$res=mysql_query('select * from students');
$cnt=mysql_num_rows($res);
echo "<br> COUNT : ".$cnt;
?>

if you still getting same then there is no record in the database in the students table. Please check the students table again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.