2

I have created php and Mysql site.Its Working Locally Xampp well. Finally I moved My site to server..i have Used Mysql Workbench. connected client database in Mysql Workbench in My system.when I Run the code its showing Error:

Validating Information....error with query: SELECT ID,fname,lname,email,userlevel,user_group,orgID FROM students WHERE username='test' AND password='123456' No connection could be made because the target machine actively refused it.

<?php

class db

{

    var $persistent=0;

    var $query;



    var $user="abaceu";

    var $pass ="******";

    var $host="*********";

    var $mydb="mysql_24172_abacu";  

    var $rlink;



    function connect()

    {

        if($this->persistent==1)

        {

        $this->rlink = mysql_connect($this->host,$this->user,$this->pass);

        }

        else

        {

        $this->rlink = mysql_connect($this->host,$this->user,$this->pass);

        }

  mysql_select_db ($this->mydb);




  }





    function query($SQL)

    {

    $this->query=mysql_query($SQL)or die( "error with query: $SQL ".mysql_error() );

    }



    function getRows()

    {

    $this->moreRows=mysql_fetch_array($this->query);



        if($this->moreRows<1)

        {

        @mysql_close($this->rlink);

        }



    return $this->moreRows;

    }



    function row($column)

    {

    return $this->moreRows[$column];

    }

    function close()

    {

        @mysql_close($this->rlink);

    }



}





/*

$db = new db;

$db->connect();

$db->query("SELECT * FROM x_groups");

//$db->query("INSERT INTO x_groups (group_ID,name) VALUES ('mm10','mystery tester 10')");



while($db->getRows())

//while(odbc_fetch_into($rlink, $row));

{ 

echo $db->row("name")."---".$db->row("group_ID")."<BR>";

} 

*/

?>

any Idea about issues? its worked xampp Local side.But Not Working Host server side ?

Philip Olson
  • 4,662
  • 1
  • 24
  • 20
Thennarasu
  • 474
  • 1
  • 6
  • 20
  • If you moved your code from test to live its likely that the location of the database and the userid and password have changed. Did you pick that up and make the changed to your connection request in PHP. As that message is basically saying you are tring to connect to somewhere that a MYSQL database does not exist – RiggsFolly Jun 29 '15 at 11:26
  • i have checked my connection with select query displaying data but my site code its showing error – Thennarasu Jun 29 '15 at 11:32
  • If `the target machine actively refused it` then there is no MySQL or the Userid/password are incorrect, but most likely you are connecting to the wrong machine or using the wrong port number. **I notice that you do not test for errors** after your `mysql_connect()` **Start by doing that** – RiggsFolly Jun 29 '15 at 11:36
  • @RiggsFolly sir i need to change my database connection code sir ? – Thennarasu Jun 29 '15 at 12:05
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jun 29 '15 at 12:09
  • _i need to change my database connection code_ Yes, so what can I do to help – RiggsFolly Jun 29 '15 at 13:23
  • changed and configure my server hosting code still i am getting error – Thennarasu Jun 29 '15 at 13:55
  • I appreciate your frustration, but how can I know what your hosting service requires. I dont eneb know what hosting provider you are using. – RiggsFolly Jun 29 '15 at 22:17
  • var $host="my03.winhost.com"; i have using – Thennarasu Jun 30 '15 at 04:29
  • Can you connect to the server at all? I find that, whenever I receive this kind of message, the service is dead and requires restarting. – Adam Frederick Wiseman Aug 18 '15 at 16:11

0 Answers0